120 likes | 235 Views
Memory management. (Overlays, swa pping & compaction). By: Francis M. Tan. WHAT IS Overlays??. - means "replacement of a block of stored instructions or data with another .“ - a method that allows programs to be larger than the computer's main memory.
E N D
Memory management (Overlays, swapping & compaction) By: Francis M. Tan
WHAT IS Overlays?? - means "replacement of a block of stored instructions or data with another.“ - a method that allows programs to be larger than the computer's main memory
Some example… (non-splitted block of codes) INCLUDE SYSLIB (MOD1) INCLUDE SYSLIB (MOD2) OVERLAY A INCLUDE SYSLIB(MOD3) INCLUDE SYSLIB(MOD4) INCLUDE SYSLIB(MOD5) INCLUDE SYSLIB(MOD6) INCLUDE SYSLIB(MOD7) Root Segment MOD1, MOD2 OVERLAY A INCLUDE SYSLIB(MOD3) INCLUDE SYSLIB(MOD4) INCLUDE SYSLIB(MOD5) INCLUDE SYSLIB(MOD6) INCLUDE SYSLIB(MOD7)
Some example… (splitted program codes) • INCLUDE SYSLIB (MOD1) • INCLUDE SYSLIB (MOD2) • OVERLAY A • INCLUDE SYSLIB(MOD3) • OVERLAY AA • INCLUDE SYSLIB(MOD4) • INCLUDE SYSLIB(MOD5) • OVERLAY AB • INCLUDE SYSLIB(MOD6) • OVERLAY B • INCLUDE SYSLIB(MOD7) Root Segment MOD1, MOD2 Overlay B MOD7 Overlay A MOD3 Overlay AA MOD3 Overlay AB MOD7
WHAT IS memory “swapping”?? • a simple memory management policy • moving of a complete / entire process IN or OUT of memory processes between main memory and secondary. • Data can be moved includes: • process blocks (pcb) • data variables (i.e. heap, stack) • codes / program instructions (in machine language) • etc…
Some example… Main Memory Secondary Memory Process 6 OS Swap OUT Process 3 Process 1 (40 KB) Swap IN Process 7 (15 KB) Process 5 Process 8 (20 KB) Process 2 Swap Space Files
WHAT IS memory “compaction”?? • Memory compaction is the process of moving allocated objects together, and leaving empty space together • also known as “burping the memory” so that huge processes can fit into memory • merging vacant holes into one
Some illustration… Compaction 1 Compaction 2 P1 = 200kb P1 = 200kb P1 = 200kb P2 = 100kb P2 = 100kb P2 = 100kb P3 = 400kb Free = 400kb Free = 900kb New Process MR = 700kb P4 = 200kb P4 = 200kb P4 = 200kb Free = 900kb Free = 300kb P5 = 300kb P6 = 400kb P6 = 400kb P6 = 400kb Free = 200kb P7 = 200kb
Multiprogramming w/ fixed partition (MFP)… • accommodates jobs into memory only when the process fit in any of the fixed sized partitions. Internal Fragmentations – is the amount of unused memory space within a partition produced when a small process is allocated to a big partition. External Fragmentations – the amount of memory regions that are available but are too small to accommodate any incoming process.
Algorithms used for mfp… • First Fit – allocation always starts at the beginning of the memory. • Best Fit – allocates an incoming job to the smallest available partition • Next Fit – modified version of FF. Starts from the beginning of the memory and allocates the job to the first hole that it finds capable of accepting the job. • Worst Fit – works in opposite manner when compared to BF. It allocates the largest hole to a particular program / process.
Multiprogramming w/ variable partition (MvP)… • in this approach, user space is deemed as one big hole in the memory before the start of process allocation. • temporary partitions are created when jobs are placed inside the memory and this partitions are erased when jobs leaves the user space