paging and segmentation
paging and segmentation
on
OPERATING SYSTEM
(ICS-401)
2023– 2024
INSTITUTE OF ENGINEERING
&TECHNOLOGY
REFERENCES :
1. Silberschatz, Galvin and Gagne, “Operating Systems Concepts”, Wiley
2. Harvey M Dietel, “ An Introduction to Operating System”, Pearson Education
3. William Stallings, “Operating Systems: Internals and Design Principles ”, 6th Edition, Pearson
Education
4. D M Dhamdhere, “Operating Systems : A Concept based Approach”, 2nd Edition
5. Sibsankar Halder and Alex A Aravind, “Operating Systems”, Pearson Education
6. Rajiv Chopra, “ Operating System a Practical approach”, S.Chand
7. I.A.Dhotre, “Operating System”,Technical Publications.
8. codeforwin.org/
9. https://www.prepbytes.com
10. Unstop.com
Advantages of Paging:
Paging avoids external fragmentation and compaction.
In paging, allocation of memory is easy and cheap.
In this technique, swapping processes is easy between equal-sized pages and frames.
Paging also solves the problem of fitting memory chunks of varying sizes onto the backing store.
The page which is just swapped out is least likely to be used again.
It allows demand paging and prepaging.
Disadvantages of Paging:
Frames are allocated as units and because of this, they may have some internal fragmentation. If the memory
requirements of a program do not happen to coincide with page boundaries, the last frame allocated may not be
completely filled and will have some free space.
For e.g, Suppose the page/frame size is 8MB and the process is 14 MB. In this case, 2 frames will be allocated but the
last frame will have 2 MB of free space.
Page tables and frame tables are used to keep the details of free and allocated space. They consume additional memory
to get stored. Every process will have its own page table in the memory.
In paging, we were blindly diving the process into pages of fixed sizes but in segmentation, we divide the process
into modules for better visualization of the process. Here each segment or module consists of the same type of
functions. For example, the main function is included in one segment, library function is kept in other segments,
and so on. As the size of segments may vary, so memory is divided into variable size parts.
Translation of logical Address into physical Address
As a CPU always generates a logical address and we need a physical address for accessing the main memory. This
mapping is done by the MMU(memory management Unit) with the help of the segment table .
Lets first understand some of the basic terms then we will see how this translation is done.
Logical Address: The logical address consists of two parts segment number and page offset.
1. Segment Number: It tells the specific segment of the process from which the CPU wants to read the data.
2. Segment Offset: It tells the exact word in that segment which the CPU wants to read.
Logical Address = Segment Number + Segment Offset
Physical Address: The physical address is obtained by adding the base address of the segment to the segment
offset.
Segment table: A segment table stores the base address of each segment in the main memory. It has two parts
i.e. Base and Limit . Here, base indicates the base address or starting address of the segment in the main
memory. Limit tells the size of that segment. A register called Segment Table Base Register(STBR) which holds
the base value of the segment table. The segment table is also stored in the main memory itself.
How is the translation done?
The CPU generates the logical address which contains the segment number and the segment offset . STBR register
contains the address of the segment table. Now, the segment table helps in determining the base address of the
segment corresponding to the page number. Now, the segment offset is compared with the limit corresponding to
the Base. If the segment offset is greater than the limit then it is an invalid address. This is because the CPU is
trying to access a word in the segment and this value is greater than the size of the segment itself which is not
possible. If the segment offset is less than or equal to the limit then only the request is accepted. The physical
address is generated by adding the base address of the segment to the segment offset.
Concept of Paging
In which processes are organized in equal size blocks called pages, and the main memory is organized in equal-sized
blocks called frames.
Pages in secondary memory and main memory frames are the same size as the CPU and do not generate absolute
addresses. But it generates the logical address.
However, the actual data required for the CPU is present in the main memory. A physical address is required to access
actual data in the main memory. For this purpose, the system uses the MMU. MMU further uses the Page table. Every
process has its own page table.
Entries of page table of each process = total no of pages of that process
Paging is a technique in which the main memory is organized in blocks of equal size. These blocks are also known as
pages. In this technique, the address of occupied pages of physical memory is stored in a table known as a page table.
Through Paging, OS can get the physical memory location without specifying the 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 the
virtual address is specified in the instruction and is smaller than the physical address of the data. It consists of two
different numbers; the first is the page’s address, known as a virtual page in the page table. The second number is the
offset value of the actual data on the page. Let’s explain with a diagram.
In an operating system, memory management refers to dividing the memory among the various processes. The
fundamental goal of memory management is to make optimal use of memory by minimizing internal and external
fragmentation. One such algorithm for memory management techniques is paging.
Operating systems utilize paging as a memory management strategy to manage memory and assign memory to
programs, so it eliminates the requirement for contiguous physical memory allocation. Paging is the procedure of
transferring operations in the form of pages from the secondary storage into the primary memory. Memory is split
into fixed-size units called pages in paging, and processes are given memory allotments based on these pages. Paging
is a logical idea that is utilized to provide quicker access to data.
What is Paging?
Paging is a static memory allocation method that allows a process's physical address space to be of a non-contiguous
type. It's a memory management scheme or storage mechanism that lets the operating system fetch processes from
secondary memory in the form of pages and place them in the main memory. The paging hardware and operating
system are integrated to implement the paging process.
A page is a logical memory unit in a program. Logical memory is organized into equal-sized pages or equal-sized
blocks. A frame is a type of physical memory unit. In the concept of paging, physical memory (main memory) is