- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Memory management plays an important part in operating system. It deals with memory and the moving of processes from disk to primary memory for execution and back again. Some basic concepts related to memory management are as follows −
Virtual Address Space and Physical Address Space
The address generated by the CPU is known as the virtual address and the address seen by the memory is known as the physical address. In compile time and load time address binding schemes, both the virtual and physical address are the same. They differ only in the execution time address binding scheme.
All the logical addresses generated by a program is known as virtual address space and all the physical addresses corresponding to these logical addresses constitute the physical address space.
Sometimes a process is swapped out of the main memory i.e removed from the main memory into the secondary storage. This may be done to make space for other processes so they can execute easily. Later the process that was swapped out can be swapped in for execution.
An image to illustrate the process of swapping is −
<p>The process P1 is swapped out i.e. moved from the main memory to secondary memory and process P2 is swapped in i.e. moved from the secondary memory to main memory for execution.
A simple way to allocate memory is to provide the empty memory spaces to incoming processes as required. This can be done using the following algorithms −
The process is allocated the first available memory space that is large enough for its purposes. Searching can start at the beginning or at the point where the last first fit search ended.
The process is allocated the smallest memory block that is large enough for its purposes. For the best fit algorithm, the entire block list needs to be searched, unless it is maintained in order.
The process is allocated the largest memory block that is available. For this algorithm also the entire block list needs to be searched, unless it is maintained in order.
In a computer system, virtual memory can be created that is more than the actual memory available i.e. physical memory. To implement this, the concept of paging is used.
In paging, the logical address space is divided into pages and the physical address space is divided into frames. The size of both the pages and frames is the same. The process is measured by the number of pages.
Now, these pages are brought from the logical address space to the physical address space by storing the pages into the frames. A page table is created to find out which page is stored in what frame.
This concept is explained more clearly using the following example −
The explanation of the above example is as follows −
- The logical address is 13 bits. In this first 3 bits represent the page number and the rest of the bits are page offset.The physical address is 12 bits. In this first 2 bits represent the frame number and the rest of the bits are page offset.
- The size of the page and frame is 1 KW. There are 8 pages in the logical address space and 4 frames in the physical address space.
- The page table specifies the location of pages in frames. It contains 8 rows, one for each page and the contents of these rows are the frame in which that particular page is stored. This is known as the page table entry.
- For example, in the page table row 7 contains value 00. That means page 7 is stored in frame 0 in the physical address space.
This is a memory management technique that supports the user view of memory. The logical address space is divided into a group of segments. These segments have a name and memory length. So, the segment address is specifies using its name, base address and length.
The segments in logical address space appear as follows −
- Memory management in Java
- Global memory management in C++ : Stack or Heap?
- C++ Program for First Fit algorithm in Memory Management
- C++ Program for Best Fit algorithm in Memory Management
- What are the changes in Memory Management in Java 9?
- Major Activities of an Operating System with Regard to Memory Management
- What are the basic components of the memory management unit in computer architecture?
- Process Management
- Cache Management
- Storage Management
- Difference between Cache Memory and Virtual Memory
- Difference between Virtual memory and Cache memory
- Transactional memory
- Difference between Volatile Memory and Non-Volatile Memory