- CPSC 461: Copyright © 2002 Katrin Becker 1998-2002 Last Modified May 20, 2000 01:52 PM
Blocking and Buffering
-
The Bridge Between The Logical and The Physical
- Block: smallest amount of data that can be read from or written to secondary storage at one time. Often generalized to mean any chunk of data that can be treated as a unit (for reading, writing, organizing). We will distinguish between disk blocks (physical) and program defined blocks (logical).
-
- - can't always ensure that logical and physical blocks match (often don't even want to).
- - should make sure they compliment each other
- - logical blocks should not be split between physical blocks
- - it's often more efficient to waste a little physical space in order to achieve a better match
- eg. logical blocks = 10 bytes; physical blocks = 32 bytes; so fit 3/p.b. (waste 2 bytes per physical block)
- Blocking: the process of grouping several components into one block
- Clustering: grouping file components according to access behaviour
- Considerations affecting block size:
- size of available main memory
- space reserved for programs (and their internal data space) that use the files
- size of one component of the block
- characteristics of the external storage device used
-
- Buffering: Software interface that reconciles blocked components of the file with the program that accesses information as single components. A buffering interface is of one of two types: blocking routine or deblocking routine.
- Blocking Routine: stores components from the program into a buffer (in main memory)
- Deblocking Routine: accesses one block from the file (,places it in memory) and sends one component at a time to the program.
- Sample Deblocking Process:
- If buffer not empty, go to step 6
- CPU issues input request
- I/O channel signals device controller for device specified in the input request
- device controller locates requested information and starts reading bytes from the device and sends them to the buffer in main memory.
- I/O channel waits until the buffer is full, then signals the CPU that I/O operation is complete, Location indicator for the buffer sent to 1.
- next component to which the location indicator points is sent to the program
- increment location indicator
- CPU continues execution of program
-
- Logical Write: writing one component to the block-sized buffer
- Physical Write: writing one block to the external file
- Double Buffering: having two buffers so one can be filled while the other is being processed
- Processor Bound: A process where more time is taken to process a block than is taken to read or write the block. In such a case, the entire process can only be made faster by increasing the efficiency of the processing part.
- Buffers
- file manager : confirms file use info; finds physical location of file on disk; makes sure required sector in buffer;
- I/O buffer: holds sectors of data; often doesn't get written back to disk until the buffer is needed for other uses (that way if more stuff done to the same sector, it doesn't have to be loaded again)
- I/O processor: may be simple chip or complex CPU;
: takes instruction from O/S, but once it starts it runs independently; it'll tell someone when it's done
disk controller : I/O processor checks w/ disk controller if it's ready; then asks to position r/w heads; when ready, I/O processor passes bytes to disk or vice-versa
buffer management:
- bottlenecks - what if only one buffer and we are alternately reading and writing - most have at least one each
- buffering strategies - trade-off is management overhead VS transfer time savings
- avoid being I/O bound by having several buffers so one can be processed while another is filled (then switch roles - double buffering)
- keep a pool of buffers (take one only when you need it)
- move mode: parts of memory are reserved for specific purposes (like system buffers and user space) - this means stuff must be moved around, sometimes A LOT
- locate mode: allows use of data directly from I/O buffer or transfer of data from device to user buffer
- scatter/ gather I/O: moves into/out of several buffers with a single READ/WRITE ; scatter: move data from one block to several buffers according to specified organization; gather: gather several buffers; write with single output
- can sometimes control buffer management through calls to O/S
-
CPSC 461: Copyright © 2002 Katrin Becker 1998-2002 Last Modified May 20, 2000 01:52 PM