DOC PREVIEW
Berkeley COMPSCI 162 - Protection: Address Spaces

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Page 1CS162Operating Systems andSystems ProgrammingLecture 11Protection: Address SpacesMarch 5, 2008Prof. Anthony D. Josephhttp://inst.eecs.berkeley.edu/~cs162Lec 11.23/5/08 Joseph CS162 ©UCB Spring 2008Review• Scheduling: selecting a waiting process from the ready queue and allocating the CPU to it• FCFS Scheduling:– Run threads to completion in order of submission– Pros: Simple (+)– Cons: Short jobs get stuck behind long ones (-)• Round-Robin Scheduling: – Give each thread a small amount of CPU time when it executes; cycle between all ready threads– Pros: Better for short jobs (+)– Cons: Poor when jobs are same length (-)Lec 11.33/5/08 Joseph CS162 ©UCB Spring 2008Review• Shortest Job First (SJF)/Shortest Remaining Time First (SRTF):– Run whatever job has the least amount of computation to do/least remaining amount of computation to do– Pros: Optimal (average response time) – Cons: Hard to predict future, Unfair• Multi-Level Feedback Scheduling:– Multiple queues of different priorities– Automatic promotion/demotion of process priority in order to approximate SJF/SRTF• Lottery Scheduling:– Give each thread a priority-dependent number of tokens (short tasksmore tokens)– Reserve a minimum number of tokens for every thread to ensure forward progress/fairness• Evaluation of mechanisms:– Analytical, Queuing Theory, SimulationLec 11.43/5/08 Joseph CS162 ©UCB Spring 2008Goals for Today• Kernel vs User Mode• What is an Address Space?• How is it Implemented?Note: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and GagnePage 2Lec 11.53/5/08 Joseph CS162 ©UCB Spring 2008Virtualizing Resources• Physical Reality: Different Processes/Threads share the same hardware– Need to multiplex CPU (Just finished: scheduling)– Need to multiplex use of Memory (Today)– Need to multiplex disk and devices (later in term)• Why worry about memory sharing?– The complete working state of a process and/or kernel is defined by its data in memory (and registers)– Consequently, cannot just let different threads of control use the same memory» Physics: two different pieces of data cannot occupy the same locations in memory– Probably don’t want different threads to even have access to each other’s memory (protection)Lec 11.63/5/08 Joseph CS162 ©UCB Spring 2008Recall: Single and Multithreaded Processes• Threads encapsulate concurrency– “Active” component of a process• Address spaces encapsulate protection– Keeps buggy program from trashing the system– “Passive” component of a processLec 11.73/5/08 Joseph CS162 ©UCB Spring 2008Important Aspects of Memory Multiplexing• Controlled overlap:– Separate state of threads should not collide in physical memory. Obviously, unexpected overlap causes chaos!– Conversely, would like the ability to overlap when desired (for communication)• Translation: – Ability to translate accesses from one address space (virtual) to a different one (physical)– When translation exists, processor uses virtual addresses, physical memory uses physical addresses– Side effects:» Can be used to avoid overlap» Can be used to give uniform view of memory to programs• Protection:– Prevent access to private memory of other processes» Different pages of memory can be given special behavior (Read Only, Invisible to user programs, etc).» Kernel data protected from User programs» Programs protected from themselvesLec 11.83/5/08 Joseph CS162 ©UCB Spring 2008Binding of Instructions and Data to Memory• Binding of instructions and data to addresses:– Choose addresses for instructions and data from the standpoint of the processor– Could we place data1, start, and/or checkit at different addresses? » Yes» When? Compile time/Load time/Execution time– Related: which physical memory locations hold particular instructions or data?data1: dw 32…start: lw r1,0(data1)jal checkitloop: addi r1, r1, -1bnz r1, r0, loop…checkit: …0x300 00000020… …0x900 8C2000C00x904 0C0003400x908 2021FFFF0x90C 1420FFFF…0xD00 …Page 3Lec 11.93/5/08 Joseph CS162 ©UCB Spring 2008Multi-step Processing of a Program for Execution• Preparation of a program for execution involves components at:– Compile time (i.e. “gcc”)– Link/Load time (unix “ld” does link)– Execution time (e.g. dynamic libs)• Addresses can be bound to final values anywhere in this path– Depends on hardware support – Also depends on operating system• Dynamic Libraries– Linking postponed until execution– Small piece of code, stub, used to locate the appropriate memory-resident library routine– Stub replaces itself with the address of the routine, and executes routineLec 11.103/5/08 Joseph CS162 ©UCB Spring 2008Administrivia• Midterm #1– Solution with grading guidelines posted– Midterms will be returned Thursday and Friday– Regrade request deadline is next Friday (3/14)• Project 2 started yesterday– Design doc due next Monday (3/10)– Code due Thursday 3/20Lec 11.113/5/08 Joseph CS162 ©UCB Spring 2008Recall: Uniprogramming• Uniprogramming (no Translation or Protection)– Application always runs at same place in physical memory since only one application at a time– Application can access any physical address– Application given illusion of dedicated machine by giving it reality of a dedicated machine• Of course, this doesn’t help us with multithreading0x000000000xFFFFFFFFApplicationOperatingSystemValid 32-bitAddressesLec 11.123/5/08 Joseph CS162 ©UCB Spring 2008Multiprogramming (First Version)• Multiprogramming without Translation or Protection– Must somehow prevent address overlap between threads– Trick: Use Loader/Linker: Adjust addresses while program loaded into memory (loads, stores, jumps)» Everything adjusted to memory location of program» Translation done by a linker-loader» Was pretty common in early days• With this solution, no protection: bugs in any program can cause other programs to crash or even the OS0x000000000xFFFFFFFFApplication1OperatingSystemApplication20x00020000Page 4Lec 11.133/5/08 Joseph CS162 ©UCB Spring 2008Multiprogramming (Version with Protection)• Can we protect programs from each other without translation?– Yes: use two special registers BaseAddrand LimitAddrto prevent user from straying outside designated area» If user tries to access an illegal address, cause an error– During switch, kernel


View Full Document

Berkeley COMPSCI 162 - Protection: Address Spaces

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Download Protection: Address Spaces
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Protection: Address Spaces and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Protection: Address Spaces 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?