This document discusses memory management techniques in operating systems, including swapping, where a process is temporarily moved from memory to disk to allow another process to run. It describes how swapping works, with processes stored on a backing store disk, and discusses allocation mechanisms like contiguous and partitioned allocation. Dynamic partitioning is covered, where processes are allocated exact amounts of memory, which can lead to external fragmentation requiring compaction. Placement algorithms for dynamic partitioning like best-fit, first-fit, and next-fit are also summarized.
This document discusses memory management techniques in operating systems, including swapping, where a process is temporarily moved from memory to disk to allow another process to run. It describes how swapping works, with processes stored on a backing store disk, and discusses allocation mechanisms like contiguous and partitioned allocation. Dynamic partitioning is covered, where processes are allocated exact amounts of memory, which can lead to external fragmentation requiring compaction. Placement algorithms for dynamic partitioning like best-fit, first-fit, and next-fit are also summarized.
This document discusses memory management techniques in operating systems, including swapping, where a process is temporarily moved from memory to disk to allow another process to run. It describes how swapping works, with processes stored on a backing store disk, and discusses allocation mechanisms like contiguous and partitioned allocation. Dynamic partitioning is covered, where processes are allocated exact amounts of memory, which can lead to external fragmentation requiring compaction. Placement algorithms for dynamic partitioning like best-fit, first-fit, and next-fit are also summarized.
• Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution • Backing store – fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images • Roll out, roll in – swapping variant used for priority-based scheduling algorithms; lower-priority process is swapped out so higher-priority process can be loaded and executed • Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped • The swapped process must swap back to the same location if the binding is done at compile time or load time. • Modified versions of swapping are found on many systems (i.e., UNIX, Linux, and Windows) • System maintains a ready queue of ready-to-run processes which have memory images on disk Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 2 Schematic View of Swapping
Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 3
Allocation Mechanisms • Contiguous allocation – Single partition allocation • Base and limit registers are used – Multiple partition allocation • Holes [external fragmentation] • Partitioned allocation – Equal size partitions • Program should fit in a partition else design with overlays • Internal fragmentation – Unequal size partitions • Queue for each partition Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 4 Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 5 Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 6 Dynamic Partitioning • Partitions are of variable length and number • Process is allocated exactly as much memory as required • Eventually get holes in the memory. This is called external fragmentation • Must use compaction to shift processes so they are contiguous and all free memory is in one block
Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 7
Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 8 Dynamic Partitioning Placement Algorithm • Operating system must decide which free block to allocate to a process • FIT algorithms to find the block – Best-fit algorithm • Chooses the block that is closest in size to the request – First-fit algorithm • Chooses the first available [from top] block that is large enough – Next-fit • Scans memory from the location of the last placement – Worst-fit • Allocate the largest hole Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 9 Tuesday, November 21, 2023 Biju K Raveendran @ BITS Pilani Goa 10