Presentation is loading. Please wait.

Presentation is loading. Please wait.

MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 

Similar presentations


Presentation on theme: "MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. "— Presentation transcript:

1 MEMORY MANAGEMENT

2 memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory.  Memory management is achieved through memory management algorithms.  Each memory management algorithm requires its own hardware support.  In this chapter, we shall see the partitioning, paging and segmentation methods. 1

3 Memory Management  Also we must make it sure that a program in memory, addresses only its own area, and no other program’s area. Therefore, some protection mechanism is also needed. 2

4 3.1 Fixed Partitioning  In this method, memory is divided into partitions whose sizes are fixed.  OS is placed into the lowest bytes of memory.  The number of fixed partition gives the degree of multiprogramming. memory OS n KBsmall 3n KBMedium 6n KBLarge 3

5 3.1 Fixed Partitioning  The main problem with the fixed partitioning method is how to determine the number of partitions, and how to determine their sizes. memory OS n KBsmall 3n KB Medium 6n KB Large small area Q medium area Q large area Q 4

6 Allocation stratagys  First-fit: Allocate the first hole that is big enough  Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size  Produces the smallest leftover hole  Worst-fit: Allocate the largest hole; must also search entire list  Produces the largest leftover hole How to satisfy a request of size n from a list of free holes First-fit and best-fit better than worst-fit in terms of speed and storage utilization

7 fragmentation memory OS 2K 6KEmpty (6K) 12Kempty Empty (3K) P2 (9K) P1 (2K) If a whole partition is currently not being used, then it is called an external fragmentation. If a partition is being used by a process requiring some memory smaller than the partition size, then it is called an internal fragmentation. 6

8 7 Dynamic Partitioning  Partitions are of variable length and number  Each process is allocated exactly as much memory as it requires  Eventually holes are formed in main memory. This is called external fragmentation  Must use compaction to shift processes so they are contiguous and all free memory is in one block  Used in IBM’s OS/MVT (Multiprogramming with a Variable number of Tasks)

9 8 Dynamic Partitioning: an example  A hole of 64K is left after loading 3 processes: not enough room for another process

10 3.2 Variable Partitioning  With fixed partitions we have to deal with the problem of determining the number and sizes of partitions to minimize internal and external fragmentation.  In the variable partitioning method, we keep a table (linked list) indicating used/free areas in memory. 9

11 compaction OS P1 12 KB 10 KB P2 20 KB P4 3 KB 13 KB P3 6 KB 4 KB 10 Memory mapping before compaction

12 compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P3 Secondary storage 11

13 12 Address Types  A physical address (absolute address) is a physical location in main memory  A logical address is a reference to a memory location independent of the physical structure/organization of memory

14 13 Simple Paging  Main memory (physical memory) is partition into equal fixed-sized frams  each process (logical memory) is also divided into chunks of the same size called pages  The process pages can thus be assigned to the available frames

15 Paging  To run a program of size n pages, need to find n free frames.  Set up a page table to translate logical to physical addresses

16 Free Frames Before allocation After allocation

17 16 Example of process loading

18 17 Page Tables  The OS now needs to maintain (in main memory) a page table for each process  Each entry of a page table consist of the frame number where the corresponding page is physically located  The page table is indexed by the page number to obtain the frame number  A free frame list, available for pages, is maintained

19 18 Logical address used in paging  Within each program, each logical address must consist of a page number and an offset within the page  A CPU register always holds the starting physical address of the page table of the currently running process  Presented with the logical address (page number, offset) the processor accesses the page table to obtain the physical address (frame number, offset)

20 Address translation

21 20 Logical-to-Physical Address Translation in Paging

22 Segmentation  Memory-management scheme that supports user view of memory  A program is a collection of segments  A segment is a logical unit such as: main program procedure function method object local variables, global variables common block stack symbol table arrays

23 User’s View of a Program

24 Logical View of Segmentation 1 3 2 4 1 4 2 3 user spacephysical memory space


Download ppt "MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. "

Similar presentations


Ads by Google