[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

getblk for buffer cache.

Posted on 2004-09-13
1
Medium Priority
?
3,579 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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