Open In App

Spooling in Operating System

Last Updated : 03 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In the Operating System, we had to provide input to the CPU, which then executed the instructions and returned the output. However, there was a flaw in this strategy. In a typical situation, we must deal with numerous processes, and we know that the time spent on I/O operations is very large in comparison to the time spent by the CPU on instruction execution. So, in the old approach, one process will provide input using an input device, and the CPU will be idle during this time. The instruction is then carried out by the CPU, and the output is once more sent to an output device while the CPU is still in an idle state. The following process begins its execution after displaying the output. As a result, the CPU sits idle the majority of the time, which is the worst situation for operating systems. Spooling is a notion that is relevant in this situation.

Spooling

Spooling is an acronym for simultaneous peripheral operation online. Spooling is the process of temporary storage of data for use and execution by a device, program, or system. Data is sent to and stored in main memory or other volatile storage until it is requested for execution by a program or computer. Spooling makes use of the disc as a large buffer to send data to printers and other devices. It can also be used as an input, but it is more commonly used as an output. Its primary function is to prevent two users from printing on the same page at the same time, resulting in their output being completely mixed together. It prevents this  because it uses the FIFO(First In First Out) strategy to retrieve the stored jobs in the spool, and that creates a synchronization preventing the output to be completely mixed together.

It also aids in the reduction of idle time, as well as overlapped I/O and CPU. Simple forms of file management are frequently provided by batch systems. The access to the file is sequential. Batch systems do not necessitate the management of time-critical devices.

Spooling in OS

 

How Spooling Works in Operating Systems?

  • Spooling requires the creation of a buffer known as SPOOL, which is used to hold off jobs and data until the device in which the SPOOL is created is ready to use and execute the job or operate on the data.
  • When a faster device sends input to a slower device to perform an operation, it acts as a SPOOL buffer by using any secondary memory attached. This input is retained in the SPOOL until the slower device is ready to use it. When the slower device is ready, the input in the SPOOL is loaded into main memory for the operations that are required.
  • A device can connect to multiple input devices, each of which may require some data processing. As a result, all of these input devices may store their data in secondary memory (SPOOL), which can then be executed sequentially by the device. This prevents the CPU from becoming idle at any time. As a result, Spooling is a combination of buffering and queuing.
  • After the CPU generates some output, this output is first saved in the main memory. This output is transferred to the secondary memory from the main memory, and from there, the output is sent to the respective output devices.

Example

  • Printing is the most obvious application of Spooling. The documents to be printed are saved in the SPOOL and then added to the printing queue. During this time, many processes can run and use the CPU without waiting while the printer runs the printing process on each document one by one.
Example of Spooling

 

Advantages

  • The spooling operation makes use of a disc as a very large buffer. 
  • It enables applications to run at the CPU’s speed while I/O devices operate at their full speed.
  • Spooling, on the other hand, is capable of overlapping I/O operations for one job with processor operations for another.

Disadvantages

  • Depending on the volume of requests received and the number of input devices connected, spooling needs a lot of storage.
  • Since the SPOOL is created in the secondary storage, having lots of input devices active at once may cause the secondary storage to fill up quickly and increase disc traffic. As a result, the disc becomes slower and slower as the volume of traffic grows.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads