SPOOL (an acronym for Simultaneous Peripheral Operations On-Line) is a buffering mechanism in which data is sent to and stored in memory or on a disk until the device accesses it for execution. Spooling is a kind of request queue where data from multiple sources are queued on the memory or buffer area for the execution based on the FIFO (first-in, first-out) algorithm.
Spooling is useful because devices access data at different rates. The buffer provides a waiting station where data can rest while the slower device catches up.
How is spooling used?
The mechanism is used in numerous computer applications:
Print spooling: In print spooling, documents are loaded into a buffer (usually an area on a disk), and then the printer pulls them off the buffer at its own rate. Because the documents are in a buffer where they can be accessed by the printer, you can perform other operations on the computer while the printing takes place in the background. Spooling also lets you place a number of print jobs on a queue instead of waiting for each one to finish before specifying the next one.
Batch processing: The system collects data to be processed. Spooling can keep the collected data in a queue until the system gets ready with the required resources to process them one by one.
Banner page: Spooling can be used to generate banner pages. Banner pages inform the printer of the beginning and the end of each printing task, and it’s helpful while more people use the same printer.
Email: Emails are transferred to a storage area by a Mail Transfer Agent, and the mails need to wait till the Mail User Agent has picked them.
How does spooling work?
- The first step is to create a secondary memory or spool to store the data till the device gets ready to execute the data.
- The spool keeps the data sent by a faster device to the slower device in its buffer area until the slower device gets ready to process the data.
- The spool can maintain a queue of data that allows the system to execute the data in FIFO order and ensure that the CPU works all the time.
- The output generated by the CPU first saves into the main memory and then transfers to the secondary memory.
- Finally, the output is sent to the output device from the secondary memory.
Advantages of spooling
- Multiple I/O devices such as keyboard, mouse, and printer can work together without causing any disruption to one another.
- The CPU does not need to wait for the I/O operations to take place as it has no interaction with the I/O devices in spooling.
- The process keeps the CPU working efficiently all the time till the queue of ready-to-run jobs gets exhausted.
Spooling vs. Buffering
Although spooling and buffering are used to improve the efficiency of the computer systems by using a storage area, there are some significant differences between them. Some of them are the following:
- Can use a significant amount area of memory
- Can overlap the I/O of one data with the computation of another
- Supports remote data processing
- Requires fewer CPU resources
- Uses a limited amount of memory (the buffer)
- Can overlap the I/O of one data with the computation of the same
- Does not support remote data processing
- Requires more resources