What is Spooling in Operating System?

Initially, when Operating System came into existence then we had to give the input to the CPU and the CPU executes the instructions and finally gives us the output. But there was a problem with this approach. In a normal situation, we have to deal with a number of processes and we know that the time taken in the I/O operation is very large as compared to the time taken by CPU for the execution of the instructions. So, in the old approach, one process will give the input with the help of an input device and during this period of time, the CPU is in idle state. Then the CPU executes the instruction and then the output is again given to some output device and at this time also, the CPU is in idle state. After showing the output, the next process starts its execution. So, most of the time, the CPU is in idle state and this is the worst condition that we can have in Operating Systems. Here, the concept of Spooling comes into play. Let's learn more about it.

Spooling

Spooling stands for " Simultaneous Peripheral Operations Online ". So, in a Spooling, more than one I/O operations can be performed simultaneously i.e. at the time when the CPU is executing some process then more than one I/O operations can also de done at the same time. The following image will help us in understanding the concept in a better way:

From the above image, we can see that the input data is stored in some kind of secondary device and this data is then fetched by the main memory. The benefit of this approach is that, in general, the CPU works on the data stored in the main memory. Since we can have a number of input devices at a time, so all these input devices can put the data into the disk or secondary memory. Then, the main memory will fetch the data one by one from the secondary memory and the CPU will execute some instruction on that data. Both the main memory and secondary memory are digital in nature, so taking data from the main to secondary is very fast. Also, when the CPU is executing some task then at that time, the input devices need not wait for its turn. They can directly put their data in the secondary memory without waiting for its turn. By doing so, the CPU will be in the execution phase most of the time. So, the CPU will not be idle in this case.

When the CPU generates some output, then that output is first stored in the main memory and the main memory transfers that output to the secondary memory and from the secondary memory, the output will be provided to some output devices. By doing so, again we are saving time because now the CPU doesn't have to wait for the output device to show the output and this, in turn, increases the overall execution speed of the system. The CPU will not be held idle in this case.

For example, in a printer spooling, there can be more than one documents that need to be printed. So, the documents can be stored into the spool and the printer can fetch that documents and print the document one by one.

Advantages of Spooling

  • Since there is no interaction of I/O devices with CPU, so the CPU need not wait for the I/O operation to take place. The I/O operations take a large amount of time.
  • The CPU is kept busy most of the time and hence it is not in the idle state which is good to have a situation.
  • More than one I/O devices can work simultaneously.

Difference between Spooling and Buffering

We all know that a buffer is an area in the main memory that is used to store and hold data temporarily. This data can be transferred between two devices or between a device and an application. The main aim of buffers is to match the speed of data streaming between a sender and receiver. There is a difference between Spooling and Buffering.

  • In spooling, the I/O of one job can be handled along with some operations of another job. While in buffering, only one job is handled at a time.
  • Spooling is more efficient than buffering.
  • In buffering, there is a small separate area in the memory know as a buffer. But spooling can make use of the whole memory.

These are some of the differences between spooling and buffering. That's it for this blog. Hope you learned something new today.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here .

Keep Learning :)

Team AfterAcademy!