Kernel I/O Subsystem : Kernels provide many sevices related to I/O. Servel services-scheduling, buffering, coaching, spooling, device reservation, and error handling-are provide by the kerne’s I/O subsytem and build on the hardware and device-driver infrastructure. The I/O subsytem is also responsible for protecting itself from errant processes and malicious users.
I/O scheduling –
To schedule a set of I/O requests means to determine a good order in which to execute them. The order in which applications issue system calls rarely is the best choice. Sceduling can improve overall system performance, can share device access fairly among processes, and can reduce the average waiting time for I/O complete. Here is a simple example to illustrate. Suppose that a disk arm is near the beginning of the disk and that three applications issue blocking read calls to hear that disk.
Operating-system developers implement scheduling by maintaining a wait queue of the requests for each device. When an application issues a blocking I/O system call, the request is place on the queue for that device. The I/O scheduler rearranges the order of the queue to improve the overall systems efficiency and the average response time experienced by applications.
Buffering –
A buffer, of cource, is a, memory area that stores data being transfer between two devices or between a device and an application. Buffering is do for three resons. One reason is to cope with a spend mismatch between the producer and consumer of a data stream. Suppose, for example, that a file is being recieve via modem for storage on the hard disk. So a buffer is create in main memory to accumulate the bytes recieved from the modem. When an entire buffer of data has arrive, the buffer can be write to the disk in a single operation.
Since the disk write is not instantaneous and the modem still needs a place to store additional incoming data, two buffers are use. After the modem fills the first buffer, the disk write is request. The modem starts to fill the second buffer while the first buffer is write to disk. By the time the modem has filled the second buffer, the disk write from the first one should have completed, so the modem can switch back to the first buffer while the disk writes the second one. This double buffering decouples the producer of data from the consumer, thus relaxing timing requirements between them.