0% found this document useful (0 votes)
4 views

Paging

Paging is a memory management technique that divides memory into fixed-size pages, allowing for faster data access and noncontiguous physical address space allocation. Each process has its own page table to translate logical addresses to physical addresses, and a valid-invalid bit is used for memory protection. Thrashing occurs when a process spends more time paging than executing due to insufficient frames, leading to low CPU utilization.

Uploaded by

vishalpalv43004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Paging

Paging is a memory management technique that divides memory into fixed-size pages, allowing for faster data access and noncontiguous physical address space allocation. Each process has its own page table to translate logical addresses to physical addresses, and a valid-invalid bit is used for memory protection. Thrashing occurs when a process spends more time paging than executing due to insufficient frames, leading to low CPU utilization.

Uploaded by

vishalpalv43004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Paging

Introduction
• Paging is a memory management technique in
which the memory is divided into fixed size
pages. Paging is used for faster access to data.
When a program needs a page, it is available
in the main memory as the OS copies a certain
number of pages from your storage device to
main memory. Paging allows the physical
address space of a process to be
noncontiguous.
Paging
• Logical address space of a process can be noncontiguous;
process is allocated physical memory whenever it is available.
 Avoids external fragmentation

• Divide physical memory into fixed-sized blocks called frames


(size is power of 2, between 512 bytes and 16 MB).
• Divide logical memory into blocks of same size called pages.
• Page Size = Frame Size
• To run a program of size n pages, need to find n free frames
and load program.
• Set up a page table to translate logical to physical addresses.

Operating System Concepts


Example

• Let us consider the main memory size 16 Kb and


Frame size is 1 KB therefore the main memory will be
divided into the collection of 16 frames of 1 KB each.
• There are 4 processes in the system that is P1, P2, P3
and P4 of 4 KB each. Each process is divided into
pages of 1 KB each so that one page can be stored in
one frame.
• Initially, all the frames are empty therefore pages of
the processes will get stored in the contiguous way.
• Let us consider that, P2 and P4 are moved to waiting state
after some time. Now, 8 frames become empty and therefore
other pages can be loaded in that empty place. The process
P5 of size 8 KB (8 pages) is waiting inside the ready queue.
• Given the fact that, we have 8 non contiguous frames
available in the memory and paging provides the flexibility of
storing the process at the different places. Therefore, we can
load the pages of process P5 in the place of P2 and P4.
Address generated by CPU is divided into
• Page number(p): Number of bits required to represent the
pages in Logical Address Space or Page number
• Page offset(d): Number of bits required to represent
particular word in a page or page size of Logical Address
Space or word number of a page or page offset.

Physical Address is divided into


• Frame number(f): Number of bits required to represent the
frame of Physical Address Space or Frame number.
• Frame offset(d): Number of bits required to represent
particular word in a frame or frame size of Physical Address

• The offset field identifies a particular location within page


or frame.
Address Translation Scheme
• Address generated by CPU is divided into:
– Page number (p) – used as an index into a page table
which contains base address of each page in physical
memory
– Page offset (d) – combined with base address to
define the physical memory address that is sent to
the memory unit
page number page offset
p d
m -n n
Paging Hardware
Concept of paging
• Every process have its own page table.

• Each page table contains the list of frames allocated to


the process.

• Page table is indexed by page no and each page no.


contains the corresponding frame no. of the memory
where that page is allocated.

Operating System Concepts


Paging Model of Logical and Physical Memory
Free Frames

Before allocation After allocation


Paging Example

Page address in physical


memory = (page size * Frame
number) + offset

Operating System Concepts


Memory Protection
• Valid-invalid bit attached to each entry in the
page table:
– “valid” indicates that the associated page is in the
process’ physical address space, and is thus a legal
page.
– “invalid” indicates that the page is not in the
process’ physical address space.

Operating System Concepts


Valid (v) or Invalid (i) Bit In A Page
Table

Operating System Concepts


Cell addressin : byte addressable , two byte addressable and so on

10 bit: -> 2 power 10 address i.e 1024 address locations:

Example:
14 bit address : size of logical ADDRESS SPACE
IN CASE OF 1 BYTE ADDRESSABLE

IN CASE OF 2 BYTE ADDRESSABLE:


Cell addressin : byte addressable , two byte addressable and so on

10 bit: -> 2 power 10 address i.e 1024 address locations:

Example:
14 bit address : size of logical ADDRESS SPACE
IN CASE OF 1 BYTE ADDRESSABLE

IN CASE OF 2 BYTE ADDRESSABLE:

Example : 64 kb , bit _________ addressable


1 byte address
2 byte addressing
Example:
LA 24b
PA 16b
ps1KB

Find page number bits and frame number bit,


offset

Operating System Concepts


Segmentation
• Memory-management scheme that supports user view of
memory.
• A program is a collection of segments. A segment is a logical
unit such as:
main program,
procedure,
function,
method,
object,
local variables, global variables,
common block,
stack,
symbol table, arrays
Operating System Concepts
User’s View of a Program

Operating System Concepts


Logical View of Segmentation
1

4
1

3 2
4

user space physical memory space

Operating System Concepts


Thrashing

• A process that is spending more time paging than executing is said to be


thrashing. In other words it means, that the process doesn't have enough
frames to hold all the pages for its execution, so it is swapping pages in
and out very frequently to keep executing. Sometimes, the pages which
will be required in the near future have to be swapped out.
• Initially when the CPU utilization is low, the process scheduling
mechanism, to increase the level of multiprogramming loads multiple
processes into the memory at the same time, allocating a limited amount
of frames to each process. As the memory fills up, process starts to spend
a lot of time for the required pages to be swapped in, again leading to low
CPU utilization because most of the proccesses are waiting for pages.
Hence the scheduler loads more processes to increase CPU utilization, as
this continues at a point of time the complete system comes to a stop.

You might also like