Solved

getblk for buffer cache.

Posted on 2004-09-13
1
3,461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 54
mixString challenge 36 134
deburging in oracle form 12 112
withoutTen challenge 14 137
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

696 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