Memory Management - Lecture Notes PDF
Document Details

Uploaded by TebogoRoss041225
2018
Tags
Related
- Artificial Intelligence & Data Science S.E. Operating Systems Past Paper PDF - 2019 Pattern
- Computer Science: Chapter 3 - Operating Systems (PDF)
- OCR Computer Science A Level 1.2.1 Systems Software Notes PDF
- Operating Systems Memory Management PDF
- Basics of Computer Systems Lecture 4 PDF
- OCR A Level Computer Science: Systems Software Notes PDF
Summary
These lecture notes cover memory management concepts, including relocation requirements, partitioning techniques such as fixed and dynamic partitioning, and memory allocation algorithms. It also explains paging and segmentation. The content references 'Operating Systems: Internals and Design Principles (Ninth Edition)' by William S. (2018).
Full Transcript
Memory Management William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Relocation Programmer does not know where the program will be placed in memory when it is executed While the program is executing, it may be sw...
Memory Management William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Relocation Programmer does not know where the program will be placed in memory when it is executed While the program is executing, it may be swapped to disk and returned to main memory at a different location (relocated) Memory references must be translated in the code to actual physical memory address William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Protection Processes should not be able to reference memory locations in another process without permission Impossible to check absolute addresses in programs since the program could be relocated Must be checked during execution Operating system cannot anticipate all of the memory references a program will make William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Sharing Allow several processes to access the same portion of memory Better to allow each process (person) access to the same copy of the program rather than have their own separate copy William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Logical organization Programs are written in modules Modules can be written and compiled independently Different degrees of protection given to modules (read-only, execute-only) Share modules William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Management Requirements Physical organization Memory available for a program plus its data may be insufficient Overlaying allows various modules to be assigned the same region of memory Programmer does not know how much space will be available William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Memory Partitioning The principal operation of memory management is to bring processes into main memory for execution by the processor. In almost all modern multiprogramming systems, this involves a sophisticated scheme known as virtual memory. Virtual memory is, in turn, based on the use of one or both of two basic techniques: segmentation and paging. Let us prepare the ground by looking at simpler techniques that do not involve virtual memory : Partitioning William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Fixed Partitioning In most schemes for memory management, we can assume the OS occupies some fixed portion of main memory, And the rest of main memory is available for use by multiple processes. The simplest scheme for managing this available memory is to partition it into regions with fixed boundaries. William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Fixed Partitioning Partition Sizes One possibility is to make use of equal-size partitions. In this case, any process whose size is less than or equal to the partition size can be loaded into any available partition. If all partitions are full, and no process is in the Ready or Running state, the operating system can swap a process out of any of the partitions and load in another process William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Fixed Partitioning Difficulties with the use of equal-size fixed partitions A program may be too big to fit into a partition. In this case, the programmer must design the program with the use of overlays so only a portion of the program need be in main memory at any one time. Main memory utilization is extremely inefficient. Any program, no matter how small, occupies an entire partition. William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Fixed Partitioning Placement Algorithm Equal-size partitions because all partitions are of equal size, it does not matter which partition is used Unequal-size partitions can assign each process to the smallest partition within which it will fit processes are assigned in such a way as to minimize wasted memory within a partition William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). 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 William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Dynamic Partitioning Placement Algorithm Compaction is time consuming OS designer must be clever in deciding how to assign processes to memory. If there is more than one free block of memory of sufficient size, OS must decide which free block to allocate. Three placement algorithms: best-fit, first-fit and next-fit. William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Dynamic Partitioning Placement Algorithm Best-fit algorithm Chooses the block that is closest in size to the request Since smallest block is found for process, the smallest amount of fragmentation is left, memory compaction must be done more often William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Dynamic Partitioning Placement Algorithm First-fit algorithm Begins to scan memory from the beginning and chooses the first available block that is large enough. William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Dynamic Partitioning Placement Algorithm Next-fit Begins to scan memory from the location of the last placement and chooses the next available block that is large enough. Compaction may be required more frequently William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). William, S. (2018). Operating Systems: Internals an d Design Principles (Ninth Edition). Buddy System In a Buddy system, memory blocks are available of size 2K words L