Chapter 10 1
Chapter 10 1
10
VIRTUA
L
DEMAND
PAGING
What is Demand Paging?
Secondary memory
Page Fault
• Access to a page marked invalid causes a page
fault.
• The procedure for handling this page fault:
We check an internal table (usually kept with
the process control block) for this process to
determine whether the reference was a valid or
an invalid memory access.
If the reference was invalid, we terminate the
process. If it was valid but we have not yet
brought in that page, we now page it in.
We find a free frame.
We schedule a secondary storage operation to
read the desired page into the newly allocated
frame.
When the storage read is complete, we
modify the internal table kept with the
process. And the page table to indicate that
the page is now in memory.
We restart the instruction that was interrupted
by the trap. The process can now access the
page as though it had always been in memory.
Pure demand paging
In pure demand paging, a process starts
execution with no pages in memory. It faults for
each required page as it encounters it, loading
them one by one into memory. Once all needed
pages are loaded, the process runs without
further page faults.
Page Table: This table has the ability to mark
an entry invalid through a valid-invalid bit.
Secondary Memory: This memory holds those
pages that are not present in main memory. It is
a high speed disk, known as swap device.
• when page fault occur, after handling it the
execution have to start from exactly the same
place from where it was interrupted.
• For example:
Executing a three-address instruction like ADD
may involve multiple steps:
• fetching the instruction, operands
• performing the addition
• storing the result.
If a page fault occurs during any step (e.g.,
storing in C), the missing page must be
brought into memory.
This requires restarting the instruction,
repeating all steps from fetching to storing.
Free Frame List
• When a page fault occurs, the operating
system brings the desired page from
secondary storage into main memory.
• To resolve page faults, most operating
systems maintain a free frame list, a pool
of free frames for satisfying such requests.
• Operating system typically allocate free
frames using a technique known as zero-
fill-on-demand.
• Zero-fill-on-demand frames are “zeroed-
out” before being allocated, thus erasing
• When a system starts up, all available
memory is placed on the free-frame list.
• As free frames are requested, the size of
the free-frame list shrinks