Operating systems

Introduction to memory virtualization

Prashanth L.A.

2023-08-28

Lecture 13 starts here

So far

 

In the next few lectures

First steps

OS in the good old days

Sharing memory in a caring OS

A real view

Address space abstraction

A virtual view

Every address you see is virtual

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    printf("location of code : %p\n", main);
    printf("location of heap : %p\n", malloc(100e6));
    int x = 3;
    printf("location of stack: %p\n", &x);
    return 0;
}

Address translation

A simple example

void func()
    int x;
...
x = x + 3; // this is the line of code we are interested in

If you dissemble

Dynamic relocation

Base and bounds

Hardware provide two registers: Base and Bounds

\[physical\ addr = virtual\ addr + base \]

\[virtual\ addr \le bounds\]

128: movl 0x0(%ebx), %eax

Hardware requirements

OS duties

OS duties at boot time

Lecture 14 starts here

OS duties at boot time

OS designer language

Relocation

What is static relocation?

movl 1000, %eax
becomes
movl 4000, %eax