Memory Management
An operating system has two main functions during memory management. One, to ensure that each process is allocated sufficient memory to prevent the operations from running into each other. Two, it ensures that resources from the cache memory, the secondary memory, and the main memory are adequately utilized to ensure efficacy when running programs. During memory management, the OS dictates the time and amount of memory to allocate to various programs depending on their needs. It tracks the location and availability of each memory space.
Operating systems handle memory management using five primary schemes; multiple-partitioned allocation, paging/virtual memory, memory segmentation, swapping, and single contiguous allocation. In single operating system instances, the partitioned and single allocation are the most implemented techniques. Single allocation refers to availing all of the free computer memory, except memory allocated to the OS, to a single application. It allows for multitasking by swapping memory contents between users. Multiple-partitioned allocation or partitioned allocation, on the other hand, refers to multiple fixed-sized divisions in memory where each partition is allocated to a specific task according to process requirements. This technique faces the challenge of size. With fixed-sized partitions, small programs will waste space while large programs face difficulty during execution. Memory segmentation is often implemented on multiple operating system instances since it ensures better access protection compared to other techniques by restricting applications from accessing memory references not defined for their segment.
One significant problem affecting memory management is external fragmentation caused when memory freed from a process breaks into pieces, which invalidates its contiguous nature. Possible solutions to external fragmentation include compaction in the operating system or paging. Compaction allows for the reconstruction of fragmented memory by shuffling the pieces into one large block. At the same time, paging removes the need for contiguous memory by storing process information in similarly sized blocks called pages. Compared to compaction, paging is simple to implement and efficient, although it is not a good solution for systems with small memory capacities. Similar sized frames and pages make swapping easy. Paging suffers internal fragmentation as the cost of reducing external fragmentation