Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. very fast very small volatile non-volatile very slow very large.
Download ReportTranscript Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. very fast very small volatile non-volatile very slow very large.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. very fast very small volatile non-volatile very slow very large Based on the von Neumann architecture, data and program instructions exist in physical memory Repeatedly perform fetch-decode-execute cycles The execute part often results in data fetch and store operations Locations in memory are identified by memory addresses When compiled, programs consist of relocatable code Other compiled modules also consist of relocatable code At load time, any additional libraries also consist of relocatable code At run time, memory addresses of all object files are mapped to a single memory space in physical memory Using dynamic loading, external libraries are not loaded when a process starts Libraries are stored on disk in relocatable form Libraries loaded into memory only when needed Using dynamic linking, external libraries can be preloaded into shared memory When a process calls a library function, the corresponding physical address is determined Main memory is partitioned and allocated to resident operating system and user processes fixed partitioning scheme A pair of base and limit registers define the logical address space Also known as relocation registers The CPU generates logical memory addresses A Memory-Management Unit (MMU) maps logical memory addresses to the physical address space User programs never see physical memory addresses Hardware protects against memory access outside of a process’s valid memory space Variable-length or dynamic partitions: When a new process enters the system, the process is allocated to a single contiguous block OS OS OS OS Process 5 Process 5 Process 5 Process 5 Process 9 Process 9 Process 8 Process 2 Process 1 Process 2 Process 2 Process 2 The operating system maintains a list of allocated partitions and free partitions How can we place new process Pi in memory? First-fit algorithm: allocate the first free block that’s large enough to accommodate Pi Best-fit algorithm: allocate the smallest free block that’s large enough to accommodate Pi Next-fit algorithm: allocate the next free block, searching from last allocated block Worst-fit algorithm: allocate the largest free block that’s large enough to accommodate Pi Memory is wasted due to fragmentation, which can cause performance issues OS Internal fragmentation is wasted memory Process 5 within a partition or process memory External fragmentation can reduce the number of runnable processes Process 8 ▪ Total memory space exists to satisfy a memory request, but memory is not contiguous Process 9 Process 2 Process 3 Process 6 Process 7 Process 12 Reduce external fragmentation by compaction or defragmentation OS Rearrange memory contents to organize Process 5 all free memory blocks together into one large contiguous block Compaction is possible only if relocation is dynamic and is done at execution time Compaction is expensive Process 9 Process 8 Process 2 Process 3 Process 6 Process 7 Process Process 12 7 Process 9 Process 12