second chance algorithm n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Second-Chance Algorithm PowerPoint Presentation
Download Presentation
Second-Chance Algorithm

Loading in 2 Seconds...

play fullscreen
1 / 17

Second-Chance Algorithm - PowerPoint PPT Presentation


  • 122 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Second-Chance Algorithm' - kane-marquez


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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
  • When a page get a second chance, it’s reference bit is cleared, and its arrival time is reset to the current time
second chance algorithm1
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
second chance algorithm2
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
additional reference bits algorithm
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
additional reference bits algorithm1
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
counting based page replacement
Counting Based Page Replacement
  • Least Frequently used (LFU) page-replacement algorithm
  • Most frequently used (MFU) page-replacement algorithm
page buffering algorithm
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
allocation of frames
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
9 6 thrashing
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
thrashing
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
thrashing1
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
thrashing2
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
solution to thrashing
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
solution to thrashing2
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