×

Operating System Tutorial

Operating System Practice

Memory Management Techniques in Operating System

In this tutorial, we will learn about the various techniques used by operating system in memory management. By Amit Shukla Last updated : May 07, 2023

Overview

Memory management function of operating system helps in allocating the main memory space to the processes and their data at the time of their execution. To learn more about Memory management of operating system you can refer Memory management in Operating System.

Memory Management Techniques

The following are the three key memory management techniques used by an operating system:

  1. Segmentation
  2. Paging
  3. Swapping

1. Segmentation

Segmentation refers to the technique of dividing the physical memory space into multiple blocks. Each block has specific length and is known as a segment. Each segment has a starting address called the base address. The length of the segment determines the availability memory space in the segment.

organization of segment in memory unit

The above figure shows the organization of segment in memory unit.

The location of data values stored in the segment can be determined by the distance of actual position of data value from base address of the segment. The distance between the actual position of data and the base address of segment is known as displacement or offset value. In other words, when there is a need to obtain data from required segmented memory then the actual address of data is calculated by adding the base address of the segment with offset value.

The base address of the segment and the offset value is specified in a program instruction itself. The following figure shows how the actual position of an operand in a segment is obtained by adding the base address and offset value.

segment and the offset value

2. Paging

Paging is a technique in which the main memory of computer system is organized in the form of equal sized blocks called pages. In this technique, the address of occupied pages of physical memory are stored in a table, which is known as page table.

Paging enables the operating system to obtain data from the physical memory location without specifying lengthy memory address in the instruction. In this technique, the virtual address is used to map the physical address of the data. The length of virtual address is specified in the instruction and is smaller than physical address of the data. It consists of two different numbers, first number is the address of page called virtual page in the page table and the second number is the offset value of the actual data in the page.

virtual address in paging - OS

The above figure shows how the virtual address is used to obtain the physical address of an occupied page of physical memory using a page table.

3. Swapping

Swapping is the technique used by an operating system for efficient management of memory space of a computer system. Swapping involves performing two tasks called swapping in and swapping out. The task of placing the pages or blocks of data from the hard disk to the main memory is called swapping in. On the other hand, the task of removing pages or blocks of data from main memory to the hard disk is called swapping out. The swapping technique is useful when larger program is to be executed or some operations have to performed on a large file.

swapping of pages in operating system

The above figure shows the Swapping of pages in operating system.

Image source: Book – Fundamental of computers by E. Balagurusamy




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.