..

OS Notes - Memory Management

Main memory management is critical because the entire system’s performance relies on the amount of memory available (in order to run processes), and the optimization of memory during job processing.

The memory manager has 4 memory allocation schemes, namely:

  • Single-user contiguous systems
  • Fixed partitions
  • Dynamic partitions
  • Relocatable dynamic partitions

Single-user contiguous systems

In this context, contiguous means that the freely available memory blocks are adjacent to each other. Basically, in this allocation scheme, only one program can be loaded into memory at any given time, and the memory is allocated as needed to accomdate the program. There is less overhead for the memory manager because the jobs are ran sequentially. As a new process comes in, the memory manager will evaluate its process size and load it into memory if it fits; else it is rejected and the memory manager continues to evaluate the next incoming process. When the process ends, the entire memory space is freed to make room for the next process.

Fixed partition

The basic idea is that we divide (partition) the entire memory size into smaller chunks (partitions), and each job is allocated a single partition. As its name suggests, the partition sizes are fixed. Here the memory manager plays the role of allocating the memory space and storing a table mapping that information. It is important that each job has only access to its own memory space for protection. As multiple jobs can be allocated to different partitions, this allows multiprogramming in which multiple programs can be run at the same time. Of course, one may notice a very obvious weakness in this allocation scheme, and that is, in the event that an incoming process size exceeds the partition size, then these jobs will have to wait or are unable to fit into memory. Likewise, if an incoming process size is very small, but a very large partition was assigned to it(assuming that partitions are allocated based on a first come first serve basis), then we will have a lot of memory wastage(internal fragmentation). Therefore, in order for fix partitioning to be effective, it is crucial that the job size is known ahead of time.

Dynamic partitions

Dynamic partitioning tries to solve the problem of fixed partitioning. As its name suggests, instead of having fixed sizes for each partition, the main memory is partitioned on a needs basis, where each job is allocated memory when it is loaded. However, dynamic partitioning suffers from external fragmentation, where there exists unused fragments between memory blocks.

References

  • Ann McHoes and Ida Flynn (2018), Understanding Operating Systems, Course Technology, 8th Edition.