Presentation is loading. Please wait.

Presentation is loading. Please wait.

Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.

Similar presentations


Presentation on theme: "Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area."— Presentation transcript:

1 Memory Management

2 Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area is carried out dynamically by the OS -- memory management System User Kernel process

3 Storage organization Cache Main memory Secondary storage Long-term Swap-file

4 What is required of memory management? n Relocation – ability to load in relative addresses – ability to translate relative into absolute (real) addresses n Protection – processes should not be able to reference memory locations of other processes without permission – it has to be provided at run time n Sharing – several processes should be able to access the same portion of main memory n Logical organization – most programs are organized in modules – the OS should be able to handle modules or segments n Physical organization – primary and secondary – support overlaying

5 Memory Management Techniques TechniqueDescriptionPro/con Fixed partitioningmemory divided in static partitions, processes need to fit in partitions to run simple to create, inefficient, internal fragmentation, small number of processes Dynamic partitioningcreated dynamically - each process is loaded in a partition of its size no internal fragmentation, more efficient, external fragmentation, compaction Simple pagingmemory is divided into equal - size frames. Processes are divided in pages and loaded in available page-frames. no external fragmentation, small amount of internal fragmentation, Simple segmentationeach process is divided in segments and loaded in dynamic partitions external fragmentation and need for compaction Virtual memory pagingas simple paging, but not ALL pages need to be loaded at the same time. overhead of complex memory management Virtual memory segmentationas simple segmentation, but not all segments need to be loaded at the same time. overhead of complex memory management

6 Virtual memory Virtual Real DAT

7 Virtual memory requirements t All memory references within a process are logical, translated to physical at run time t A process may be broken up into a number of pieces (pages or segments) t There is no need for all the pages or all segments of a process to be in main memory at the time of execution t Only a resident set of the process needs to be in memory

8 Paging n Page table for each process l frame location of each page of the process l program: logical address is a page number plus an offset (d) within the page l page table: physical address is a frame number plus an offset (d) within the frame l the processor should use the page table to do the translation l page tables can be big, stored in virtual storage n Page table mechanisms l inverted page tables: one entry for each real page rather than virtual page l translation lookaside buffer: a page table cache l page fault, roll-in, roll-out, thrashing l direct and associative mapping

9 Segmentation ä memory is seen as a set of segments, multiple address spaces ä segments can be of variable size ä segment table to each process l logical address: segment number, offset (d) l physical address: memory address, segment length ä data structures (variable length) can be assigned to segments ä programs can be developed and maintained by segments ä increases code reuse and sharing ä supports protection ä combined paging and segmentation (s,p,d)

10 Policies for virtual memory ä Fetch policy: demand and prepaging ä Placement policy: relevant for segmentation ä Replacement policy l optimal l first-in, first-out (FIFO) l least recently used (LRU) l clock policy and variations (1 used, 0 not) – selects 0, every time it tests turns 1s in 0s – second bit for page modification l page buffering ä Locality: temporal and spatial ä Cleaning policy: demand, precleaning and buffering

11 Page fault and page size Page size Page fault Page size is a hardware design decision (remember DAT) Small page size decrease internal fragmentation, but Small page size increase the number of pages in table, and Small page size increase page fault Some computer page sizes: 512 bytes - VAX, IBM AS/400; 4 Kbytes - IBM370, PowerPC; 4 Kbytes to 4 Mbytes - Pentium


Download ppt "Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area."

Similar presentations


Ads by Google