600 likes | 741 Views
6. Memory Management and Processor Management. Management of Resources. Measure of Effectiveness On most modern computers, the operating system serves as the primary resource manager allocating and managing: Processor Time Memory Space Peripheral Devices Secondary Storage Space Data
E N D
6 Memory Management and Processor Management
Management ofResources • Measure of Effectiveness • On most modern computers, the operating system serves as the primary resource manager allocating and managing: • Processor Time • Memory Space • Peripheral Devices • Secondary Storage Space • Data • Program Libraries
Management ofResources • Measure of Effectiveness • A well-designed operating system attempts to optimize the utilization pf all the system resources. • Resource management is a key operating system function. • The operating system’s job is to manage the computer system’s resources as efficiently as possible.
Processor Management • Processor Management • Concerned with managing the processor’s time.
Memory Management • Memory Management • Concerned with managing the computer’s available pool of memory: • Allocating space to application routines and making sure that they do not interfere with each other.
Operating System Management Routines • Resident • A routine that stays in memory because it directly supports application programs as they run. • Transient • A routine that is loaded as needed. • Transient area • Memory for application programs and transient routines.
Fig. 6.2: The operating system (Resident & Transient Routines) occupies low memory. The remaining memory is the transient area.
Overlay Structures • Developed when the amount of available memory was limited. • Divide the program into logically independent modules. • Module 1 holds the main control logic and key data common to the entire program. • Module 2 processes valid input data. • Module 3 processes errors. • Module 4 generates end-of-program statistics.
Fig. 6.9a: Overlay structures. The complete program consists of four modules.
Fig. 6.9c: When an error occurs, module 3 overlays module 2.
Memory Management Concurrency • A program cannot process data it does not have. • A program spends more time waiting for I/O than processing data.
Memory Management Concurrency • Resolution – • Put a additional programs into memory. • Where ? • How ?
Fig. 6.3: Multiple programs are loaded and executed concurrently.Where?????How?????
Memory ManagementPartitions and Regions • Fixed-Partition Memory Management • Regions – Dynamic Memory Management.
Memory ManagementPartitions • Fixed-Partition Memory Management • Divides the available space into fixed-length partitions • Each partition can execute a program • Partition size is set when the operating system is generated.
Fig. 6.4: Fixed-partition memory management divides the available space into fixed-length partitions.
Memory ManagementPartitions • Fragmentation occurs because • With Fixed-Partition Memory Management • It is assumed that a given program must be loaded into contiguous memory. • Not all the space assigned to a partition may be used
Memory ManagementRegions • Regions - Dynamic Memory Management • The transient area is treated as a pool of free space • When a program needs to be executed • A region of memory just sufficient to hold the program is allocated from the transient pool • The program is loaded into this region
Fig. 6.5:Under dynamic memory management, a region of memory just sufficient to hold the program is allocated when the program is loaded.
Memory ManagementRegions • Fragmentation occurs because • With Dynamic Memory Management • It is assumed that a given program must be loaded into contiguous memory. • With dynamic allocation, bits of unused space is spread throughout memory.
Memory ManagementRegions • Regions - Dynamic Memory Management • Utilizes: • Segmentation • Paging
Memory ManagementRegions • Segmentation: • Programs are divided into independently addressed segments and stored in non-contiguous memory.
Memory ManagementSegmentation • When a program is loaded into memory: • the operating system builds a segment table for the program listing the absolute entry point address of each of the program’s segments. • As the program executes, addresses must be translated from relative to absolute form. • Base + Displacement • Segment + Displacement
Fig. 6.6: With segmentation, programs are divided into independently addressed segments and stored in noncontiguous memory.
Fig. 6.7: Dynamically translating a segment address to an absolute address.
Memory ManagementPaging • A program is broken into fixed-length pages (2k – 4K) • The pages are loaded into noncontiguous memory. • As the pages are loaded into memory, a page table is created. • Page Addresses: • Page Number • Page Displacement
Fig. 6.7: Dynamically translating a page address to an absolute address.
Memory ManagementSegmentation and Paging • Addresses are divided into: • A segment number • A page number within that segment • A displacement within that page • After the ICU expands the relative address: • The program’s segment table is searched for the segment number which yields the address of the segment’s page table • The page table is searched for the page’s base address which is added to the displacement to get an absolute address.
Memory ManagementVirtual Memory • Three Levels of Storage • Real Memory • Main memory, directly addressable by the processor • External Paging Device • Disk • Virtual Memory • Acts just like real memory, but isn’t real memory.
Memory ManagementVirtual Memory • Divides main storage into 2K sections called pageframes. • Divides all programs into 2K sections called pages. • When the operating system loads a program for execution, it first divides the program into pages and stores the pages on a disk file called the PAGE DATA SET. • The operating system then loads the pages of the program that are initially active into main (real) storage. • When a part of the program which is not in real storage is needed, a PAGE FAULT occurs. The operating system loads the page containing that code into real storage.
Memory ManagementVirtual Memory • When real storage is completely filled with active pages and another page is needed in real storage: • The operating system selects a page that has been in real storage the longest without being referenced; • Writes it back on the Page Data Set (page-out) if the contents of the page have been changed since it was first brought into realstorage; • Brings in the new page into real storage (page-in).
Memory ManagementVirtual Memory • Virtual address dynamically translated • Thrashing • excessive paging • Seriously degrades system performance
Multiprogramming • Interrupt • An electronic signal • A program surrenders control of the processor when it requests an I/O operation and is eligible to continue when the I/O operation is completed.
Multiprogramming • Interrupts can originate with: • Software • A program issues an interrupt to request the operating system’s support Hardware for an I/O operation • Hardware • Hardware issues an interrupt to notify the processor that an asynchronous event has occurred. • Illegal operations
Multiprogramming • Control Block • Created to hold a partition’s key control flags, constants, and variables. • Linked to form a linked list • The Dispatcher determines which program is to start by following the chain of pointers from control block to control block.
Scheduling and Queuing • As programs enter the system, they are placed on a queue by the queuing routine. • When space becomes available, the scheduler selects a program from the queue and loads it into memory.
Fig. 6.13: The dispatcher decides which program to start by following a linked list of control blocks.
Fig. 6.12: The operating system’s dispatcher decides which ready program executes first.
Fig. 6.14a: The program issues an interrupt, requesting the operating system’s support.
Fig. 6.14b: The interrupt handler sets the program to a wait state.
Fig. 6.14c: After the Interrupt Handler Routine starts the requested I/O operation, the dispatcher starts another application program.
Fig. 6.14d: The channel signals the end of the I/O operation by sending the processor an interrupt.