What is spooling in Linux?
Spooling refers to a process of transfering data by placing it in temporary working area whereanother program may access it for processing at a later point in time. 'Spool ' can refer to theaction of a storage device that incorporates a physical spool or reel, such as tape drive.For eg:- A printer can serve only one job at a time, several applications may wish to print theiroutput concurrently, without having their output mixed together. The operating system solvesthis problem by intercepting all output to the printer. Each applications's output is Spooledto a separate disk file. When an application finishes printing, the spooling system queues thecorresponding spool file for output to the printer. The spooling system copies the queued spoolfiles to the printer one at a time.In some operating system, spooling is managed by a system daemon process. In other operatingsystems, it is handled by an in-kennel thread.In either case, the operating system provides a control interface that enables users and systemadministrators to display the queue, to remove unwanted jobs before those jobs print to suspendprinting while the printer is serviced, and so on.Some devices, such as tape drives and printers, cannot usefully multiplex the I/O requests ofmultiple concurrent applications. Spooling is one way that operating systems can coordinateconcurrent output. Another way to deal with concurrent device access is to provide explicitfacilities for coordination.Some operating systems (including VMS) provide support for exclusive device access, byenabling a process to allocate an idle device, and to deallocate that device when it is no longerneeded. Other operating systems enforce a limit of one open file handle to such a device.Many operating systems provide functions that enable processes to coordinate exclusive accessamong themselves. For instance, Windows NT provides system calls to wait until a deviceobject becomes available. It also has a parameter to the open () system call that declares thetypes of access to be permitted to other concurrent threads. On these systems, it is up to theapplications to avoid deadlock.THE SPOOLING MECHANISMThe entire key to spooling is a synchronous processing, where the program is not constrained bythe speed of slow devices, particularly printers.Printers are relatively slow peripherals. In comparison, disc devices and particularly CPU'sare orders of magnitude faster. Without spooling print data, the speed of program operationis constrained by the slowest device, commonly printers, forcing the program to wait for themechanical motion of the printer, the program is known as "print bound'.