




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of memory management and protection in operating systems. It discusses the need for protection in multiprogramming systems, the evolution of operating systems from uniprogramming to multiprogramming with protection, and the implementation of protection through hardware-based and software-based approaches. The document also covers the concept of address translation and dual mode operation.
Typology: Slides
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Physical memory Abstraction: virtual memory No protection Each program isolated from all others and from the OS
Limited size Illusion of infinite memory
Sharing visible to programs Transparent --- can’t tell if memory is shared Easy to share data between Controlled sharing of data programs
n hardware-based approach n address translation (support of address space) n dual mode operation: kernel vs. user mode n software-based approach n type-safe languages n software fault isolation
n load application into low memory n load OS into high memory n application can address any physical memory location n application can corrupt OS and even the disk
Physical Memory
0x
Operating System
Application
0xFFFFFF
int y; extern int z;
int foo() { int x;
bar(); y = 1; z = 1; } [foo.c]
int z;
void bar() { z = 99; }
main() { foo(); } [bar.c]
Link: Need to patch references to “bar”, “foo”, and “z”
Load: Need to relocate all addresses based on what programs are running
n Problem of linker-loader --- still no protection: bugs in any program can cause other programs to crash, even OS n Goal: how to support protection?
n keep user programs from crashing/corrupting OS n keep user programs from crashing/corrupting each other
n address translation n dual mode operation: kernel vs. user mode
n type safe languages n software fault isolation
n Address space : state of an active program n Hardware translates every memory reference from virtual addresses to physical addresses n Software sets up and manages the mapping in the translation box
n Protection: there is no way for programs to talk about other program’s addresses
CPU
Translation Box
(MMU) (^) physical memory
virtual address
physical address
Data read or write
n when in the OS, can do anything (kernel-mode) n when in a user program, restricted to only touching that program’s memory (user-mode) HW can require CPU to be in kernel-mode to modify address translation table
n OS runs in kernel mode (untranslated addresses) n User programs run in user mode (translated addresses)
n No. Only the specific ones that the OS says are ok.
n via registers n write data into user memory, kernel copies into its memory except: user addresses --- translated kernel addresses --- untranslated
n main problem : addresses the kernel sees are not the same addresses as what the user sees
n sets processor status to kernel mode n changes execution stack to an OS kernel stack n saves current program counter n jumps to handler routine in OS kernel n handler saves previous state of any register it uses
n same as with threads, except n also save and restore pointer to translation table n to resume a program: reload registers, change PSW, and jump to old PC.
n How does Nachos’s structure fit into this model? n Nachos is the portable OS layer – it simulates the hardware and machine- dependent layer, and it simulates the execution of user programs running on top n Can still use debugger, printf, etc. n Can run normal UNIX programs concurrently with Nachos n Could run Nachos on real hardware by writing a machine-dependent layer
Application
Application library
Portable OS layer
Machine dependent layer
User mode
Kernel mode