Memory Management

Computer ScienceMCAOperating System

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.

Swapping

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 −

Swapping <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.

Memory Allocation

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 −

First Fit

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.

Best Fit

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.

Worst Fit

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.

Paging

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 −

Paging

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.

Segmentation

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 −

Segmentation

raja
Published on 16-Aug-2018 11:06:07
Advertisements