Prerequisite – Microkernel
The kernel provides many services related to I/O. Several services such as scheduling, caching, spooling, device reservation, and error handling – are provided by the kernel, s I/O subsystem built on the hardware and device-driver infrastructure. The I/O subsystem is also responsible for protecting itself from the errant processes and malicious users.
- I/O Scheduling –
To schedule a set of I/O request means to determine a good order in which to execute them. The order in which application issues the system call are the best choice. Scheduling can improve the overall performance of the system, can share device access permission fairly to all the processes, reduce the average waiting time, response time, turnaround time for I/O to complete.
OS developers implement scheduling by maintaining a wait queue of the request for each device. When an application issue a blocking I/O system call, The request is placed in the queue for that device. The I/O scheduler rearrange the order to improve the efficiency of the system.
- Buffering –
A buffer is a memory area that stores data being transferred between two devices or between a device and an application. Buffering is done for three reasons.
- First is to cope with a speed mismatch between producer and consumer of a data stream.
- The second use of buffering is to provide adaptation for data that have different data-transfer sizes.
- Third use of buffering is to support copy semantics for the application I/O, “copy semantic ” means, suppose that an application wants to write data on a disk that is stored in its buffer. it calls the write() system’s call, providing a pointer to the buffer and the integer specifying the number of bytes to write.
Q. After the system call returns, what happens if the application of the buffer changes the content of the buffer?
Ans. With copy semantic, the version of the data written to the disk is guaranteed to be the version at the time of the application system call.
- Caching –
A cache is a region of fast memory that holds a copy of data. Access to the cached copy is much easier than the original file. For instance, the instruction of the currently running process is stored on the disk, cached in physical memory, and copied again in the CPU’s secondary and primary cache.
The main difference between a buffer and a cache is that a buffer may hold only the existing copy of a data item, while cache, by definition, holds a copy on faster storage of an item that resides elsewhere.
- Spooling and Device Reservation –
A spool is a buffer that holds the output of a device, such as a printer that cannot accept interleaved data streams. Although a printer can serve only one job at a time, several applications may wish to print their output concurrently, without having their output mixes together.
The OS solves this problem by preventing all output continuing to the printer. The output of all applications is spooled in a separate disk file. When an application finishes printing then the spooling system queues the corresponding spool file for output to the printer.
- Error Handling –
An Os that uses protected memory can guard against many kinds of hardware and application errors, so that a complete system failure is not the usual result of each minor mechanical glitch, Devices, and I/O transfers can fail in many ways, either for transient reasons, as when a network becomes overloaded or for permanent reasons, as when a disk controller becomes defective.
- I/O Protection –
Errors and the issue of protection are closely related. A user process may attempt to issue illegal I/O instructions to disrupt the normal function of a system. We can use the various mechanisms to ensure that such disruption cannot take place in the system.
To prevent illegal I/O access, we define all I/O instructions to be privileged instructions. The user cannot issue I/O instruction directly.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Kernel in Operating System
- Difference between Operating System and Kernel
- Allocating kernel memory (buddy system and slab system)
- File System Implementation in Operating System
- System Protection in Operating System
- System Programs in Operating System
- Web Operating System
- Bad Block in Operating system
- Thread in Operating System
- Inode in Operating System
- Multithreading in Operating System
- Concurrency in Operating System
- Best-Fit Allocation in Operating System
- Segmentation in Operating System
- Introduction of Operating System - Set 1
- Paging in Operating System
- Functions of Operating System
- Time Sharing Operating System
- Deadlock Ignorance in Operating System
- Swap Space in Operating System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.