New version page

UCI ICS 143 - OS Lecture10-13

Upgrade to remove ads
Upgrade to remove ads
Unformatted text preview:

ICS 143 - Principles of Operating Systems Lectures 10,11,12 and13 - Memory Management Prof. Dmitri V. Kalashnikov dvk (@) Slides © Prof. Nalini Venkatasubramanian.Outline n Background n Logical versus Physical Address Space n Swapping n Contiguous Allocation n Paging n Segmentation n Segmentation with PagingBackground n Program must be brought into memory and placed within a process for it to be executed. n Input Queue - collection of processes on the disk that are waiting to be brought into memory for execution. n User programs go through several steps before being executed.Virtualizing Resources"n Physical Reality: Processes/Threads share the same hardware"q Need to multiplex CPU (CPU Scheduling)"q Need to multiplex use of Memory (Today)"n Why worry about memory multiplexing?"q The complete working state of a process and/or kernel is defined by its data in memory (and registers)"q Consequently, cannot just let different processes use the same memory"q Probably don’t want different processes to even have access to each other’s memory (protection)"Important Aspects of Memory Multiplexing"n Controlled overlap:"q Processes should not collide in physical memory"q Conversely, would like the ability to share memory when desired (for communication)"n Protection:"q Prevent access to private memory of other processes"n Different pages of memory can be given special behavior (Read Only, Invisible to user programs, etc)"n Kernel data protected from User programs"n Translation: "q Ability to translate accesses from one address space (virtual) to a different one (physical)"q When translation exists, process uses virtual addresses, physical memory uses physical addresses""Names and Binding q Symbolic names → Logical names → Physical names n Symbolic Names: known in a context or path q file names, program names, printer/device names, user names n Logical Names: used to label a specific entity q inodes, job number, major/minor device numbers, process id (pid), uid, gid.. n Physical Names: address of entity q inode address on disk or memory q entry point or variable address q PCB addressBinding of instructions and data to memory q Address binding of instructions and data to memory addresses can happen at three different stages. n Compile time: q If memory location is known apriori, absolute code can be generated; must recompile code if starting location changes. n Load time: q Must generate relocatable code if memory location is not known at compile time. n Execution time: q Binding delayed until runtime if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g. base and limit registers).Binding time tradeoffs q Early binding q compiler - produces efficient code q allows checking to be done early q allows estimates of running time and space q Delayed binding q Linker, loader q produces efficient code, allows separate compilation q portability and sharing of object code q Late binding q VM, dynamic linking/loading, overlaying, interpreting q code less efficient, checks done at runtime q flexible, allows dynamic reconfigurationMulti-step Processing of a Program for Execution n Preparation of a program for execution involves components at:"q Compile time (i.e., “gcc”)"q Link/Load time (unix “ld” does link)"q Execution time (e.g. dynamic libs)"n Addresses can be bound to final values anywhere in this path"q Depends on hardware support "q Also depends on operating system"n Dynamic Libraries"q Linking postponed until execution"q Small piece of code, stub, used to locate appropriate memory-resident library routine"q Stub replaces itself with the address of the routine, and executes routine"Dynamic Loading n Routine is not loaded until it is called. n Better memory-space utilization; unused routine is never loaded. n Useful when large amounts of code are needed to handle infrequently occurring cases. n No special support from the operating system is required; implemented through program design.Dynamic Linking n Linking postponed until execution time. n Small piece of code, stub, used to locate the appropriate memory-resident library routine. n Stub replaces itself with the address of the routine, and executes the routine. n Operating system needed to check if routine is in processes’ memory address.Overlays n Keep in memory only those instructions and data that are needed at any given time. n Needed when process is larger than amount of memory allocated to it. n Implemented by user, no special support from operating system; programming design of overlay structure is complex.OverlayingLogical vs. Physical Address Space q The concept of a logical address space that is bound to a separate physical address space is central to proper memory management. n Logical Address: or virtual address - generated by CPU n Physical Address: address seen by memory unit. q Logical and physical addresses are the same in compile time and load-time binding schemes q Logical and physical addresses differ in execution-time address-binding scheme.Memory Management Unit (MMU) n Hardware device that maps virtual to physical address. n In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. n The user program deals with logical addresses; it never sees the real physical address.Swapping q A process can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution. q Backing Store - fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images. q Roll out, roll in - swapping variant used for priority based scheduling algorithms; lower priority process is swapped out, so higher priority process can be loaded and executed. q Major part of swap time is transfer time; total transfer time is directly

View Full Document
Download OS Lecture10-13
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...

Join to view OS Lecture10-13 and access 3M+ class-specific study document.

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

Join to view OS Lecture10-13 2 2 and access 3M+ class-specific study document.


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

Already a member?