Virtual Memory

Manage memory to allow multiple processes to share it

Issues in sharing physical memory

Protection

  • Bug in one process can corrupt memory in another
  • Prevent A from trashing or observing B‘s memory
    Transparency
  • Process shouldn’t require particular physical memory bits
    Resource Exhaustion
  • Programmes typically assume machines has enough memory
  • Sum of sizes of all processes often greater than physical memory

Goal

Give each program its own virtual Address Space

Advantages

Definitions

Virtual address

Physical address

Idea 1: Load-time Linking

Idea 2: Base + Bound Register

Idea 3: Segmentation

Idea 4: Paging

Where does the OS live?

Kernel addresses are in the same address space as the user process

Breakpoint

Top of heap

VM System Calls

char *brk(const char *addr);
char *sbrk(int incr);

Memory mapped files

Exposing page faults

sigaction is used to specify what action to take for SIGSEGV (invalid memory access)

struct sigaction { /* the Linux struct for signal actions */
	union { /* system will have one of these signal handlers */
		void (*sa_handler)(int);
		void (*sa_sigaction)(int, siginfo_t *, void *);
	};
	sigset_t sa_mask; /* signal mask to apply */
	int sa_flags; /* options, e.g. for dealing with children */
};
int sigaction (int sig, const struct sigaction *act, struct sigaction *oact)

VM Tricks

Pmap Layer