1 / 17

Second-Chance Algorithm

Second-Chance Algorithm. Basically, it’s a FIFO algorithm When a page has been selected, we inspect its reference bit. If the value is 0, we proceed to replace this page, otherwise, we give the page a second chance and move on to select the next FIFO page

seda
Download Presentation

Second-Chance Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Second-Chance Algorithm • Basically, it’s a FIFO algorithm • When a page has been selected, we inspect its reference bit. • If the value is 0, we proceed to replace this page, otherwise, we give the page a second chance and move on to select the next FIFO page • When a page get a second chance, it’s reference bit is cleared, and its arrival time is reset to the current time

  2. Second-Chance Algorithm • When a page get a second chance, it’s reference bit is cleared, and its arrival time is reset to the current time • If a page is used often enough to keep its reference bit set, it will never be replaced

  3. Second-Chance Algorithm • One way to implement the second-chance algorithm is as a circular queue • In the worst case, when all bits are set, the pointer cycles through the whole queue, giving each page a second chance • Enhanced second-chance algorithm

  4. Second-Chance Algorithm

  5. Additional-Reference-Bits Algorithm • We can gain additional ordering information by recording the reference bits at regular intervals. • We can keep 8-bit byte for each page in a table in memory • The OS shifts the reference bit for each page into the high-order bit of its 8-bit byte, shifting the other bit right by 1 bit and discard the low-order bit

  6. Additional-Reference-Bits Algorithm • For example: 00000000 means the page has not been used for eight-time interval • 11111111 means a page that is used at least once in each period • 11000100 has used more recently with both value of 01110111 and 00111111

  7. Counting Based Page Replacement • Least Frequently used (LFU) page-replacement algorithm • Most frequently used (MFU) page-replacement algorithm

  8. Page Buffering Algorithm • We can keep some amount of frames (for example 3 frames) always free • When a page fault occurs, the system does not have to wait the execution of replace algorithm. • The system can load the page into free space and swapped out frames

  9. Allocation of Frames • When we have more than one processor, we need to allocate frames to each processor • Two major algorithms: • 1. equal allocation • 2. proportional allocation

  10. Allocation of Frames

  11. 9.6 Thrashing • If the process does not have “enough” number of frames it needs to support page in active use, it will quickly page-fault • If the number of frames allocated to a process falls below the minimum number required by the process, thrashing will happen • Thrashing: The process spending more time paging than executing • Thrashing results in severe performance problems

  12. Thrashing • If CPU utilization is too low, we increase the degree of multiprogramming by introducing a new process to the system • Now, suppose that a process enters a new phase in its execution and needs more frames • It causes page faults which requires paging device to swap pages in and out • CPU utilization therefore decreases

  13. Thrashing • The trade off between CPU utilization and degree of multiprogramming • When thrashing has occurred, system throughput plunges. The page fault rate increases tremendously • As a result, no work is getting done since the processes are spending all their time paging

  14. As the degree of multiprogramming increases, CPU utilization also increases If the degree of multiprogramming is increased even further, thrashing sets in, and CPU utilization drops sharply Under this situation, we must decrease the degree of multiprogramming Thrashing

  15. Solution to Thrashing • By considering Page-fault Frequency (PFF) • This is trying to prevent thrashing • Since Thrashing has a high page-fault rate, we need to control that • We can establish upper and lower bounds on the desired page-fault rate

  16. Solution to Thrashing

  17. Solution to Thrashing • If the page-fault rate increases and no free frames are available, we must select some process and suspend it. • The freed frames are then distributed to processes with high page-fault rates

More Related