You are on page 1of 7

p

Performance of demand paging


Let
p

be the probability of a page fault


p

0 e p e1

We expect

to be close to zero, that is there will be only

a few page faults. The effective access time is effective access time
! (1  p )ma  p v

page fault time

To compute the effective access time, we must know how much time is needed to service a page fault. A page fault causes the following sequence to occur:

1. Trap to the operating system. 2. Save the user registers and process state. 3. Determine that the interrupt was a page fault. 4. Check that the page reference was legal and determine the location of the page on the disk. 5. Issue a read from the disk to free a frame. a. Wait in a queue for this device until the read request is serviced. b. Wait for the device seek and / or latency time. c. Begin the transfer of the page to a free frame 6. While waiting, allocate the CPU to some other user (CPU scheduling is optional). 7. Interrupt from the disk (I/O completed).

8. Save the registers and process state for the other user (if step 6 executed). 9. Determine that the interrupt was from the disk. 10. Correct the page table and other tables to show that the desired page is now in memory. 11. Wait for the CPU to be allocated to this process again. 12. Restore the user registers, process state, and new page table, then resume the interrupted instruction.

Note all these steps are necessary in every case. For example, we are assuming that, in step 6, the CPU is allocated to another process while the I/O occurs. This arrangement allows multiprogramming to maintain CPU untilization, but requires additional time to resume the page-fault service routine when the I/O transfer is complete. In any case, there are major components of the page-fault service time: 1. Service the page-fault interrupt. 2. Read in the page 3. Restart the process.

The first and third tasks may be reduced, with careful coding, to several hundred instructions. They may take from 1 to 100 microseconds each, The page-switch time is close to 24 milliseconds. A typical hard disk has an average latency of 8 milliseconds, a seek of 15 milliseconds, and a transfer time of 1 millisecond. Thus, the total paging time is close to 25 milliseconds, including hardware and software time. We are looking at only the device-service time. If a queue of processes is waiting for the device (other processes that have caused page faults), we have to add device-queueing time as we wait for the paging device to be free to service our request, increasing even more the time to swap.

If we take an average page-fault service time of 25 milliseconds and a memory access time of 100 nanoseconds, then the effective access time in nanoseconds is Effective access time ! 1  p v 100  p v 25 milliseconds
! (1  p ) v 100  p v 25,000,000 ! 100  24,999,900 v p

We see then that the effective access time is directly proportional to the page-fault rate. If one access out of 1000 causes a page fault, the effective access time is 25 microseconds. The computer would be slowed down by a factor of 250 because of demand paging. If we want less than 10-percent degradation, we need

110 " 100  25,000,000 v p 10 " 25,000,000 v p p 0.0000004

To keep the slowdown due to paging to a reasonable level, we can allow only less than 1 memory access out of 2,500,000 to page fault.