Solved

getblk for buffer cache.

Posted on 2004-09-13
1
3,442 Views
Last Modified: 2013-12-26
hello everyone,

      here is a part of the algorithm for getblk() function used for
acquiring buffers from a buffer cache pool in a sysVr2 kernel as defined
in M J Bacuhe Design of Unix OS (p 44):

algo getblk
input: file sys no, block no
output: locked buffer that can now be used for block
{
      while(block not found){
           if(block in hash queue){
                 if(buffer busy){
                       sleep(event: buffer becomes free)
                       continue;
                  }
                   mark buffer busy;
                   remove buffer from list;
                   return buffer;
            }
            .
            .
            .
            (other part not of concern)
}
            if the buffer is marked busy, the process is put to sleep, there by scheduling another process to run(which may again request for the same block). so we can have a number of proceses contending for the same buffer, on a disk interrupt, all these sleeping processes wd be woken up by the interrupt handler routine but only one process successfully acquires the buffer and others go to sleep again. this scheme doesnt gaurantee that a process will not be starved waiting for a buffer. so the question is, is it possible to modify the above part of the getblk() function so that there is no starvation? what i could think was that getblk() should constantly poll for availiability of the buffer till it eventually recieves it due to a disk interrupt.

        while(block in hash queue){
              if(buffer busy)
                     continue;
         .
         .

 obviously this is not a good solution, i wanted to know if its possible  to code getblk() in a way so that there is no starvation.

thanks a lot.
van_dy
0
Comment
Question by:van_dy
1 Comment
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 12042545
Hi van_dy,

>  is it possible to modify the above part of the getblk() function so that there is no starvation?
Yes, look into Lamport's bakery algorithm
http://www.cs.wvu.edu/~jdm/classes/cs356/notes/mutex/Bakery.html

Sunnycoder
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 79
windows 10 how make picture as desktop background 2 65
Hibernate methods 2 77
matchUp  challenge 9 115
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question