What is Spooling in Operating System?

Learn via video courses
Topics Covered

Before learning about Spooling in operating system, let's learn a bit about the Operating system.

An operating system is system software that acts as an interface between the user and the system or hardware. For example, when we go to a bank we cannot withdraw money directly instead we have to take the help of a bank employee who acts as an interface between the bank and the user.

It provides a convenient environment in which a user can execute the programs. An operating system is a resource manager that hides the hardware's internal working complexity so that users can perform a specific task without any difficulty.

The Core component of an operating system is known as a Kernel which acts as a bridge between the hardware and the application software. The kernel manages tasks such as memory management, task management, and disk management.

There are different types of operating systems which are as follows:

  • Single Process Operating System
  • Batch Operating System
  • Multitasking Operating System
  • Multiprogramming Operating System
  • Multiprocessing Operating System
  • Distributed Operating System
  • Real-Time Operating System

An operating system manages various resources and tasks of a computer system. OS has different important functions some of which are as follows:

  • Processor Management
  • Security
  • File Management
  • Error Detection
  • Job Accounting
  • Networking
  • Input/Output Management, etc.

To know more about Operating Systems in detail, refer to the article What is Operating System.

Now, let's get back to our topic what is Spooling in an operating system.

Spooling also known as Simultaneous Peripheral Operations Online is an I/O management or buffer management technique that allows the data of the input/output processes to be temporarily stored in the secondary memory which will be executed by the CPU or a device or a program. These data will be stored in the secondary memory until the system or a program requests the data for its execution.

Previously, when the existence of an operating system came, it used to give input to the CPU, and then the CPU executes that particular data or input and then accordingly produces the output.

Now, in this process there exist a problem where the number of processes is more, and as we already know the I/O processes or operations take relatively more time than the CPU takes for the execution of the same.

After the completion of one process, the next process starts its execution which is one of the worst conditions in an OS as its main goal is to provide maximum CPU utilization, and in this process, the CPU is idle for most of the time. Here, the existence of spooling came to play.

Peripheral equipment or I/O devices like keyboards, mouse, printers, etc, are slower devices when compared to CPU and main memory. Therefore, if a peripheral device interacts directly with the CPU for its execution then the overall performance of the system will be bottlenecked as the I/O device or peripheral device will take more time as compared to the CPU which will eventually also result in bad CPU utilization.

In Spooling, the data stored in the secondary memory or buffer is transferred to the main memory (RAM). This helps in proper utilization of the CPU as the CPU directly interacts with the main memory rather than the I/O devices which is as fast as the processing of a CPU.

There may be several input devices that store the input data on the secondary memory at a single time which are then fetched by the main memory and then the CPU executes the input data. As both the CPU and main memory are digital so they are very fast which also makes the fetching and execution fast so that the CPU should not be idle.

A stored data and instructions queue is known as a SPOOL. The SPOOL is executed in a First In First Out (FIFO) order which means the first instruction in the SPOOL will be executed first.

process-of-spooling-in-os

The above image shows the process of spooling in the operating system in a better way.

Application of Spooling

There are several different scenarios where the concept of spooling in the operating system is used. Let's discuss some of the scenarios:

  • In Batch Operating System, the system uses the spooling technique to maintain the queue or spool of ready-to-be-executed jobs in the form of punch cards. These jobs will be stored in the spool until the system maintains the required resource to process them one by one.
  • The process of spooling is most commonly used in I/O peripheral devices like printers. In the printing process, the documents are first stored in a queue or spool which is also known as the printer spooler. According to the process of spooling, the documents are fetched from the spool for printing once the printer is ready.

printer-spooler

  • Due to spooling in the operating system, there can be overlapping of multiple tasks at the same time which means that any process can continue its operations even if any I/O operations are carried out in the system. For example, multiple processes can send documents to be printed to a printer spooler without waiting and the processes can continue to work.
  • The process of spooling in the operating system is also used in the printing of computer banner pages which separates documents or files from each other and then identify the sender of the printing request with the help of the Account number, username, etc.
  • Spooling is used in the E-mail delivery system. As the mail is delivered by the Mail Transfer Agent (MTA) and stored in a temporary storage area which will be picked up by the Mail User Agent (MA).

Advantages of Spooling

Now, let's discuss some of the advantages of spooling in operating system:

  • The very first advantage of Spooling is there is no direct interaction of I/O devices with the CPU and therefore CPU does not have to wait for the I/O operations as the I/O devices have relatively slow processing speed as compared to the CPU.
  • CPU will not stay idle in the case of spooling as the CPU will finish the execution of all the tasks the SPOOL which keeps the CPU busy for most of the time.
  • Spooling supports the working of multiple I/O devices or operations simultaneously without any kind of disturbance or interference.
  • The speed of the CPU is much faster and therefore spooling allows the application to be executed at the same speed and the operations of I/O devices are carried out at their respective speed.

How Spooling Works in Operating Systems?

Now, Let's understand in detail the total internal mechanism used in spooling process. In Short, let's get a brief idea about the working of Spooling in operating systems. The steps are as follows:

  • STEP 1- As we have discussed earlier, in spooling a memory area or queue or buffer is created which is known as a SPOOL. The SPOOL is filled with the data and jobs sent by the I/O devices. The SPOOL will hold the jobs until the system or CPU is ready to execute or perform operations on the jobs.
  • STEP 2- In Spooling the faster device like the CPU takes the data from the main memory (RAM) which interacts with the secondary memory which acts as the SPOOL buffer and contains the required jobs to be executed. When the input/output device is ready to send the data then that data is transferred into the RAM or main memory for performing the required operations.
  • STEP 3- The process of spooling has the advantage of executing the jobs inside the SPOOL buffer or queue in the FIFO order that is First In First Out. Spooling process takes the entire secondary memory as the buffer which stores the jobs and data for the operations.
  • STEP 4- The CPU utilization is more when compared to the traditional I/O operations processing. As the I/O devices are slow and the main memory and CPU are digital and therefore it is fast. So, every input devices send the data to the secondary memory making a SPOOL or queue of jobs and then the jobs are transferred into the main memory. After which they are executed one by one by the CPU.
  • STEP 5- After execution of the jobs by the CPU, the output generated will be first transferred into the main memory and then to the secondary memory. This output is then transferred to the concerned output devices.

working-of-spooling-in-os

Difference between Spooling and Buffering

Buffering is also I/O management or memory management technique in which a small area of memory which is known as a buffer is considered for the temporary storage of the data. Buffering is used to match the speed of data processing between two devices that is sender and receiver.

The process of Buffering and Spooling is a bit different when compared side by side.

Let's discuss some of the differences between Spooling in an operating system and Buffering in an Operating system:

spooling-in-os

buffering-in-os

ParameterSpoolingBuffering
DefinitionSpooling technique allows the data of the input/output processes to be temporarily stored in the secondary memory (SPOOL) which will be executed by the CPU or a device or a program.Buffering is a technique that allows the data to be stored in a small area of memory known as a buffer which will help to match the speed of data processing.
ImplementationIn spooling, there is an overlapping of input/output of one job with another job's computationIn buffering, there is an overlapping of input/output of one job with the same job's computation.
EfficiencyThe process of spooling is more efficientBuffering is less efficient as compared to spooling.
Size RequiredSpooling considers the entire secondary storage as a SPOOL for the storage of jobs.In Buffering, a small area of the main memory is considered as a buffer.
ResourceThe process of Spooling requires less resource management as different resources manage the different process of a particular job.The process of buffering requires less resource management as one resource manages the process of one job.
ProcessingSpooling supports remote processing where the spooler has to notify the remote site when a process has completed its executionBuffering does not support the technique of remote processing.

Conclusion

  • Spooling is an I/O management or buffer management technique that allows the data of the input/output processes to be temporarily stored in the secondary memory.
  • The data will be stored in the secondary memory until the system or a program requests the data for its execution.
  • The stored data and instructions queue is known as a SPOOL.
  • The SPOOL is executed in a First In First Out (FIFO) order which means the first instruction in the SPOOL will be executed first.
  • The best advantage of Spooling is that there is no direct interaction of I/O devices with the CPU.
  • CPU will not stay idle in the case of spooling as the CPU will finish the execution of all the tasks the SPOOL which keeps the CPU busy for most of the time.
  • In Batch Operating System, the system uses the spooling technique to maintain the queue or spool of ready-to-be-executed jobs in the form of punch cards.
  • The process of spooling is most commonly used in I/O peripheral devices like printers. In the printing process, the documents are fetched from the spool for printing.