LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Processor priority level for Algorithm for Buffer Allocation (https://www.linuxquestions.org/questions/programming-9/processor-priority-level-for-algorithm-for-buffer-allocation-780994/)

manavendra 01-09-2010 01:23 AM

Processor priority level for Algorithm for Buffer Allocation
 
The algorithm for reading and writing disk blocks use the algorithm getblk to allocate buffers from the pool.

In the algorithm getblk, if the kernel removes a buffer from the free list, it must raise the processor priority level to block out interrupts before checking the free list. Why ?

Code:

algorithm getblk
input: file system number
      block number
output: locker buffer that can now be used for block
{
    while (buffer not found)
    {
        if (block in hash queue)   
        {
              if (buffer busy)
              {
                    sleep (event buffer becomes free)
                    continue;
              }
              mark buffer busy;
              remove buffer from free list;
              return buffer;
          }
          else
          {
                if (there are no buffers on free list)
                ...
                ...
                ...
          }
    }
}

Where can i find the C implementation of the above algorithm for buffer allocation in the linux source code ?

neonsignal 01-09-2010 06:21 PM

Are you referring to the code in fs/buffer.c?

I'm not familiar with this code, but the reason for blocking out interrupts before checking a list would be to prevent the list changing while it is being accessed.


All times are GMT -5. The time now is 09:22 PM.