0% found this document useful (0 votes)
18 views19 pages

Chapter 10 1

Uploaded by

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

Chapter 10 1

Uploaded by

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

CH #

10
VIRTUA
L
DEMAND
PAGING
What is Demand Paging?

For One option Another Lazy


program is to load strategy is swapper –
execution the entire to load never brings
it have to program in pages only a page into
be first physical as they are memory
loaded memory at needed. This unless page
into program technique is will be
memory. execution known as needed.
time. demand
paging.
Pages are Pages that are With demand
loaded only never accessed paging, the
when they are are thus never memory is
demanded loaded in to used more
during physical efficiently.
program memory.
execution.
Less I/O
needed, no
unnecessary
I/O
Less memory
needed
 Faster
response
Basic Concept
• In demand paging, ,while a process is
executing, some pages will be in memory, and
some will be in secondary storage.
• Thus we need valid-invalid bit scheme to
distinguish between two.
• Valid bit(1,v): the page is available in
physical memory.
• In-valid bit(0,i): the page is not present
in physical memory but present in
secondary memory.
frames pages

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

List of free frames.


Page fault causes following sequence
to occur
• Trap to the operating system.
• Save the registers and process state.
• Determine that the interrupt was a page
fault.
• Check that the page reference was legal
and determine the location of the page in
secondary storage.
• While waiting, allocate the CPU core to
some other process.
• Receive an interrupt from the storage I/O
subsystem (I/O completed).
• Save the registers and process state for
the other process.
• Determine that the interrupt was from
the secondary storage device.
• Correct the page table and other tables
to show that the desired page is now in
memory.
• Wait for the CPU core to be allocated to
this process again.
Performance of demand paging
• Demand paging can significantly affect the
performance of computer system.
• Page Fault Rate 0 ≤ p ≤ 1.0
• If p=0 no page faults
• If p=1, every reference is fault
• effective access time =
(1 − p) × ma + p × page
fault time.
Memory access time
(Page fault overhead + swap page
+swap page out + Restart overhea
• there are three major task components of
the page-fault service time:
 Service the page-fault interrupt.
 Read in the page.
 Restart the process
• EXAMPLE
• Memory access time=200 ns
• Average page-fault service time= 8 ms
• EAT=(1 − p) × (200) + p (8 ms)
=(1−p) ×200+p×8,000,000ns
=200-200p+8,000,000p
=200+7,999,800×p.
• If one access out of 1,000 causes a page
fault ,then
EAT=8.2 µs
• This is slowdown by factor of 40.
• Effective access time ∞ page fault rate.

You might also like