Memory ManagementSlide 2Slide 3Address BindingMemory Management RequirementsSlide 6Slide 7Slide 8Slide 9Simple Memory ManagementFixed PartitioningSlide 12Slide 13Placement Algorithm with PartitionsSlide 15Slide 16Dynamic PartitioningDynamic Partitioning: an exampleSlide 19Placement AlgorithmPlacement Algorithm: commentsReplacement AlgorithmBuddy SystemExample of Buddy SystemSlide 25Slide 26Buddy Systems: remarksRelocationAddress TypesAddress TranslationSimple example of hardware translation of addressesExample Hardware for Address TranslationSimple PagingExample of process loadingExample of process loading (cont.)Page TablesLogical address used in pagingLogical address in pagingSlide 39Logical-to-Physical Address Translation in PagingSimple SegmentationSlide 42Logical address used in segmentationLogical-to-Physical Address Translation in segmentationSimple segmentation and paging comparison1Memory ManagementMemory ManagementChapter 8Chapter 82Memory ManagementMemory ManagementIt is the task carried out by the OS and hardware to accommodate multiple processes in main memoryIf only a few processes can be kept in main memory, then much of the time all processes will be waiting for I/O and the CPU will be idle Hence, memory needs to be allocated efficiently in order to pack as many processes into memory as possible3Memory ManagementMemory ManagementIn most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processesWhat is the location in main memory of the active (running, ready, blocked) processes?It is not fixed: how do we write programs, then?4Address BindingAddress BindingAddresses in the source program are generally symbolicSymbolic addresses are bound to absolute addressesBinding can be done at any different stepsCompile time: if compiler knows where the process will resideLoad time: the loader binds the relocatable addresses produced by the compiler to absolute addressesExecution time: if the process can be moved during its execution from one memory segment to anotherMore on this later5Memory Management RequirementsMemory Management RequirementsRelocationprogrammer cannot know where the program will be placed in memory when it is executeda process may be (often) relocated in main memory due to swappingswapping enables the OS to have a larger pool of ready-to-execute processes memory references in code (for both instructions and data) must be translated to actual physical memory address6Memory Management RequirementsMemory Management RequirementsProtectionprocesses should not be able to reference memory locations in another process without permissionimpossible to check addresses at compile time in programs since the program could be relocatedaddress references must be checked at run time by hardware7Memory Management RequirementsMemory Management RequirementsSharingmust allow several processes to access a common portion of main memory without compromising protectioncooperating processes may need to share access to the same data structurebetter to allow each process to access the same copy of the program rather than have their own separate copy8Memory Management RequirementsMemory Management RequirementsLogical Organizationusers write programs in modules with different characteristics instruction modules are execute-onlydata modules can be read and/or writtensome modules are private others are publicTo effectively deal with user programs, the OS and hardware should support a basic form of module to provide the required protection and sharing9Memory Management RequirementsMemory Management RequirementsPhysical Organizationsecondary memory is the long term store for programs and data while main memory holds program and data currently in usemoving information between these two levels of memory is a major concern of memory management (OS)it is highly inefficient to leave this responsibility to the application programmer (no offense)10Simple Memory ManagementSimple Memory ManagementAn executing process must be loaded entirely in main memory (if user-implemented overlays are not used)Although the following simple memory management techniques are not used in modern OS, they lay the ground for a proper discussion of virtual memoryfixed partitioningdynamic partitioningsimple pagingsimple segmentation11Fixed PartitioningFixed PartitioningPartition main memory into a set of non overlapping regions called partitionsPartitions can be of equal or unequal sizes12Fixed PartitioningFixed PartitioningAny process whose size is less than or equal to a partition size can be loaded into the partitionIf all partitions are occupied, the operating system can swap a process out of a partitionA program may be too large to fit in a partition. The programmer must then design the program with overlays (overlays also allows for larger-than-memory programs)When the module needed is not present the user program must load that module into the program’s partition, overlaying whatever program or data are there13Fixed PartitioningFixed PartitioningMain memory use is inefficient. internal fragmentation: Any program, no matter how small, occupies an entire partition.Unequal-size partitions lessens these problems but they still remain...Also, how do you choose partition sizes?Equal-size partitions was actually used in early IBM’s OS/MFT (Multiprogramming with a Fixed number of Tasks)14Placement Algorithm with PartitionsPlacement Algorithm with PartitionsEqual-size partitionsIf there is an available partition, a process can be loaded into that partitionBecause all partitions are of equal size, it does not matter which partition is usedIf all partitions are occupied by blocked processes, choose one process to swap out to make room for the new processOnly need a bit-vector to mark which partitions are free/used15Placement Algorithm with PartitionsPlacement Algorithm with PartitionsUnequal-size partitions: use of multiple queuesAssign each process to the smallest partition within which it will fitTries to minimize internal fragmentationProblem: some queues will be empty if no processes within a size range is present16Placement Algorithm with PartitionsPlacement Algorithm with PartitionsUnequal-size partitions: use of a single queueWhen its time to load a process into main
View Full Document