- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Major Activities of an Operating System with Regard to Memory Management
Memory management plays an important part in the operating system. It deals with memory and the moving of processes from disk to primary memory for execution and back again.
Some activities of an operating system with regards to memory management are −
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 first available memory space that is large enough for the process purposes is allocated. Searching can start at the beginning or at the point where the last first-fit search ended.
The smallest memory block that is large enough for the process purposes is allocated For the best-fit algorithm, the entire block list needs to be searched unless it is maintained in order.
The largest memory block that is available is allocated to the process. For this algorithm also the entire block list needs to be searched unless it is maintained in order.
Sometimes a process is removed from the main memory and into the secondary storage. This is known as swapping. Later the process that was swapped out can be swapped in for execution. One of the reasons for swapping is to make space for other processes so they can execute easily.
An image to illustrate the process of swapping is −
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.
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 5 contains value 11. That means page 5 is stored in frame 3 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 −