This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Monday, April 20 Quiz #1 Comments on Program #1 reviews: Still not finished ... I actually read these Confidential, not returned Often used for recommendation letters Use professional language, spellcheck Be specific: Describe how your team meets and assigns tasks Describe and score each team member's contributions Today's topics
Logical / physical addresses Memory allocation User mode / Kernel mode Background (VonNeumann) Any program that is to be executed must be Input queue : collection of processes in secondary storage that are waiting to be loaded into memory. loaded into memory placed within a process User programs go through several steps before being executed. Memory management is implemented through a logical address space that is bound to the physical address space Logical address generated by a process Logical vs. Physical Address Space Physical address also referred to as virtual address. address used by the memory unit. Instructions/data must be stored in memory at specific physical addresses Address Binding Binding logical addresses to physical memory addresses can happen at three different stages. Compile time: If memory location is known in advance, absolute code can be generated Must recompile code if starting location changes. Load time: Compiler must generate relocatable code Execution time: Binding delayed until run time Need hardware support for address maps (e.g., base and limit registers). MemoryManagement Unit (MMU) Hardware device that maps virtual to physical address. In MMU, each process has a relocation register value is added to every virtual address generated by the process to give the absolute address Dynamic Loading Routines might not be loaded until they are called Better memoryspace utilization Useful when large amounts of code are needed to handle cases that occur infrequently. unused routines are never loaded. Dynamic Linking Process might invoke a routine (or another process) that must be dynamically loaded Linking is postponed until execution time. Dynamic loading/linking is particularly useful for libraries. (e.g., Windows .dll files) Overlays Keep in memory only those instructions and data that are needed for a given time frame. Useful when a process is larger than amount of memory that can be allocated to it. Swapping A process, routine, or overlay can be swapped temporarily out of memory to disk, and then brought back into memory for continued execution. Swapping takes time More later on application to virtual memory Major part of swap time is transfer time Access time (find item in secondary storage) Transfer time (copy disk memory) total transfer time is directly proportional to the number of bytes of memory swapped. Contiguous Allocation Relocation register scheme is used to protect user processes from each other, and from changing operatingsystem code and data. Relocation register (per process) contains value of lowest physical address for a process Limit register (per process) contains range of logical addresses Contiguous Allocation Each logical address must be less than the limit register. Each logical address is translated to a physical address by adding the value in the relocation register. The user program deals with logical addresses; it never sees the physical addresses. Contiguous Allocation (Cont.) Hole block of available memory When a process arrives, it is allocated memory from a hole large enough to accommodate it. Operating system maintains information about: a) allocated partitions b) free partitions (holes) E.G., process 8's space is deallocated, so processes 9 and 10 can be loaded.
OS process 5 OS process 5 OS process 5 process 9 process 8 process 2 process 2 process 2 OS process 5 process 9 process 10 process 2 holes of various size are scattered throughout memory. Dynamic StorageAllocation
How to satisfy a request of size n from a list of holes. Firstfit: Allocate the first hole that is big enough. Bestfit: Allocate the smallest hole that is big enough Worstfit: Allocate the largest hole must search entire list (unless ordered by size) produces the smallest leftover hole. must also search entire list (unless ordered by size) produces the largest leftover hole. Fragmentation External Fragmentation enough total memory space exists to satisfy a request, but it is not contiguous. Internal Fragmentation allocated memory may be larger than requested memory memory space internal to a partition, but not being used. happens when memory is allocated in fixed size blocks Fragmentation Reduce external fragmentation by compaction Shuffle memory contents to place all free memory together in one large block. Compaction is possible only if relocation is dynamic, and is done at execution time. Kernel mode Note: all "system work" is done in kernel mode So far, that includes all Much more to be discussed ... CPU scheduling, context switching System calls I/O requests Interrupt handling Dynamic loading/linking Address binding Process management/execution User mode / Kernel mode An operating system executes a variety of programs (jobs) User programs execute in user mode until ... usually several simultaneously Other system programs may execute independently System programs (e.g. scheduling) and exception handlers execute in kernel mode User program calls a system program or issues an I/O request User program issues interrupt or throws an exception CPU scheduler runs Etc. DualMode Operation Sharing system resources Hardware supports at least two modes of operation. 1. User mode execution done on behalf of a user. 2. Monitor mode (aka kernel mode or system mode) execution done on behalf of operating system. OS must ensure that an incorrect program cannot cause other programs to execute incorrectly. Dualmode operation Mode bit provided by hardware Can distinguish when system is running user code or kernel code Some instructions designated as privileged Allows OS to protect itself and other system components System call, interrupt, or fault causes switch to kernel mode. Return from call resets to user mode Privileged instructions can be issued only in kernel mode. Transition from User to Kernel Mode Questions? Read Love Chapter 11 ...
View Full Document
This note was uploaded on 06/28/2009 for the course CS 411 taught by Professor Staff during the Spring '08 term at Oregon State.
- Spring '08
- Operating Systems