What does spool mean for printing?

8,541

Solution 1

A print spool is effectively a buffer, managed per job, with a program (the spooler) responsible for receiving jobs from submitting programs and feeding them to one or more printers. The point of a spool is to handle communication between two systems with different speeds, and to control access to shared devices. The former means programs can submit print jobs as fast as they want, and those jobs are dealt with as fast (or slowly) as printers can handle. The latter (as pointed out by RonJohn) ensures that jobs are handled coherently: thus when printing, jobs aren’t mixed up.

Networked printers provide their own spools, and print servers (CUPS, lpd etc.) also implement spools. Most print systems also handle access control, quotas, banners, print options etc. Spools are used in other contexts; for example, tape-based backup servers now spool backup data from networked hosts on a fast disk-based storage system, so that they can then feed modern tape drives at the tremendous speeds they need to avoid tape shoe-shine.

In the context of the comment, the relevance of a spool is that it decorrelates the print job submission from its fulfillment. Not spooling would mean that the submission would only complete with the print job, and thus your lpr command would only complete once the job completed. Removing the spool on your computer might not have the desired result though since the printer itself could spool too!

Solution 2

In a nutshell, a spooler consists of:

  • a background program
  • a directory per printer
  • a file per print job

In your case, the foreground program (lpr) sends its print jobs to cups, which stores it and then uses serial, parallel, USB, network, ... communication to actually start the printing process.

So that's why nowadays even when the printer runs out of paper you can still continue using your computer, whereas back when I was a kid on CP/M, the whole computer locked up until you added more paper...

Why is it called "spooling"?

Because in those times, large computers used tape to store these kind of files as disks were too expensive, so when you were working inside the machine room data center, the first thing you would hear was the tapes starting to spin up¹ and only after a second or 3-4 the printer would start printing (if you were lucky). ;-)

Note 1: A "spool" is a noun meaning "a cylindrical device on which magnetic tape can be wound", therefore "spooling" is the cylindrical device spinning up and winding up tape...

Solution 3

First, let’s begin with the meaning of the term “spooling”: sometimes the size of a document is larger than the printer’s memory, so “printer spooling” allows the sending of multiple documents to a printer and putting all theses documents in a queue.

Now, under Unix there are two printing systems:

  1. The BSD spooling system uses lpd daemon to schedule the print jobs.
  2. The SVR4 spooling system uses lpsched as the scheduler.

Jeff Lessem’s USAIL: Unix system administration independent learning has a section on Printing under Unix which provides a good overview of both the BSD and SVR4 systems:

The BSD spooling system

extends well to large, heterogeneous networks allowing many computers to share printers.

Under the BSD spooling system, access to printers is controlled by lpd daemon and the lpr program. lpr is the only program on a BSD system that can queue files for printing.

lpr accepts data to be printed, puts it in a spooling directory, and notifies the lpd daemon. For each print job, lpr creates two files, a control file (cfxxx) and a data file (dfxxx) in the spool directory, xxx indicating a unique job-id. The control file contains the information for handling the print job, including the identity of the owner. The data file contains the actual data to be printed.

The lpd daemon checks the /etc/printcap file to identify the destination printer. If the destination printer is a local device, lpd makes sure a copy of the lpd daemon is running on that print queue. Otherwise lpd opens a connection to the remote host to which the printer is connected and transfers both the control and data file to it.

Print jobs are scheduled by lpd on a First-In, First-Out (FIFO) basis. However, the system administrator may use the lpc command to alter the priority of the jobs in the print queue.

SVR4 spooling system is used by Solaris and HP-UX. It offers more control and flexibility but was not designed for network printing and is more complicated to set up.

Under SVR4 spooling system, the lp command accepts the data to be printed, makes a copy of it in the spool directory associated with the destination. The destination consists of a printer name and an optional specification of a class to which the printer belongs. When the specified printer is busy the job is sent to another printer in the same class. The spool directory is normally /var/spool/lp/request/printer-name and the print file is given a unique name to identify both the job and the user.

Access to the printer is controlled by lpsched daemon. It picks up the jobs from the spool directory and sends them to appropriate destination when it becomes available. lpsched also keeps a log, usually in /usr/spool/lp/log. The log file would indicate any error in processing the print jobs, as well as the user-name,

See also: Printers and printer spooler – lp, lpstat and cancel commands | Tips & Tricks for IT's Blog

Solution 4

Never forget that SPOOL is an acronym for Simultaneous Peripheral Operations On Line. Since the early (but not earliest) days of computing, processors generated results faster than the printers could print them. Without spooling, the processor could not finish a "print job" until the printing itself was finished. This often resulted in an idle processor, waiting around for the printer.

A great leap forward in spooling came during the American space program. The computers were producing results too slowly, so a new spooling system was written just for NASA (although it and its successors gained in popularity until all IBM systems had them). It was called the Houston Automatic Spooling Program, making HASP the first nested acronym.

A good analogy to spooling is a thread factory -- thread is spun at a fast rate, and stored -- where else -- onto a spool. Then the spool of thread is eventually put on a sewing or other machine, that runs at a much slower rate, where it is used to create a finished product.

Solution 5

Spooling is a fairly old school term. Nowadays you'll see "Print Queue" used more often.

To Queue is a British saying to "wait in line". So print jobs are "queued", ie waiting in line to print.

After a job has finished spooling (there can be long "thinking" times between print lines), then it is printed, generally in a FIFO basis but Print Job priority can override it.

Print spools and queues can be paused for Operators to change paper. The can also be restarted if some pages were damaged.

Share:
8,541

Related videos on Youtube

Tim
Author by

Tim

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on September 18, 2022

Comments

  • Tim
    Tim over 1 year

    Mark wrote a comment for me

    I don't know offhand how to make cups not spool, that is, how to make the lpr command only exit after the printer driver has run.

    What does "spool" for printing mean?

    Google says it is a verb meaning "send (data that is intended for printing or processing on a peripheral device) to an intermediate store." What is the intermediate store that printing spool represents, for example, when printing by lpr command

    Mark seems to relate the meaning of spool with blocking. But I can't figure that out by looking at the definition given by Google.

    Thanks.

  • Stephen Kitt
    Stephen Kitt over 5 years
    It’s nice to mention your sources...
  • Admin
    Admin over 5 years
    I didn't finish yet ;-)
  • Tim
    Tim over 5 years
    Thanks. Is spool with the same meaning used for other tasks than printing?
  • Stephen Kitt
    Stephen Kitt over 5 years
    Yes, see my update.
  • Tim
    Tim over 5 years
    Linux kernel has buffer for read() and write(). Is that buffer also called "spool"?
  • Stephen Kitt
    Stephen Kitt over 5 years
    No, it’s not called “spool”.
  • Tim
    Tim over 5 years
    Which part of the meaning of "spool" make it not applicable to the IO buffer of Linux kernel?
  • Tim
    Tim over 5 years
    Thanks. Also does an operation having a buffer imply that the operation is nonblocking? read() and write() are blocking, although having buffer.
  • Kusalananda
    Kusalananda over 5 years
    The mail system is often using a mail spool under /var/spool/mail or similar location. This is also a "buffer" to allow for close to asynchronous sending of mail messages. The mail message is spooled/queued and the mail client does not have to wait for the mail to actually leave the system. Very much like a printing job.
  • Jennifer
    Jennifer over 5 years
    Also, the alternative to spooling in CUPS is PDQ -- Print, Don't Queue. Once a program generates something to print, it goes right to the printer, and then the program is blocked until that snippet of print actually comes out onto hard copy. Program and print finish at the same time. FWIW, I've never actually gotten PDQ to work.
  • John H
    John H over 5 years
    Note that that derivation of "spool" is widely considered to be a backronym, and "PDQ" definitely is.
  • pipe
    pipe over 5 years
    It's obviously a backronym constructed after the fact. It's becoming a fad to spread such rumours. A lot of them are listed here, maybe it's time to add "spool" to it!
  • Stephen Kitt
    Stephen Kitt over 5 years
    @Tim it’s not really a question of it being applicable or not, it’s just not called a spool. Buffers generally do result in the operations feeding into the buffer being nonblocking: write completes as soon as the data is written into whatever buffer is used (in Linux, the page cache), not once the data is really at its destination. read isn’t necessarily non-blocking either, and can return less data than was requested.
  • RonJohn
    RonJohn over 5 years
    Note also that -- in addition to handling "communication between two systems with different speeds" -- spools serialize access to those slower devices. (You can imagine how bad it would be for multiple jobs to all write to the printer or modem at the same time...)
  • Stephen Kitt
    Stephen Kitt over 5 years
    Excellent point @RonJohn, thanks; I’ve integrated it into the answer.
  • OrangeDog
    OrangeDog over 5 years
    More directly, "spool" is a noun meaning "a cylindrical device on which magnetic tape can be wound"
  • Fabby
    Fabby over 5 years
    @OrangeDog: incorporated into answer, thanks! :-)
  • Anthony Geoghegan
    Anthony Geoghegan over 5 years
    I'd suggest using Markdown formatting to make it clear which text is your own and which is quoted. You should also credit the original author, Jeff Lessem as explained in unix.stackexchange.com/help/referencing
  • Jennifer
    Jennifer over 5 years
    @pipe No, SPOOL is NOT a reverse acronym. It dates back to the 1970's, and if it is, then where did the word come from? There is nothing else to suggest its origin. (I agree with you about PDQ, however. Its original meaning was Pretty Damn Quick, meaning right away, which is what CUPS' PDQ does.)
  • Jennifer
    Jennifer over 5 years
    @chrylis see the above
  • IMSoP
    IMSoP over 5 years
    @Jennifer While IBM certainly had a program called SPOOL, it's widely conjectured, as in the Jargon File link above, that they either chose that name as a sort of pun, or derived it from an existing term. Either way, it probably refers to loading the jobs onto a spool of tape and then playing them back. In modern usage, it refers neither to an obsolete IBM product nor a spool of tape, so the whole debate is rather academic and tangential to the question of what it means today.
  • Jennifer
    Jennifer over 5 years
    @IMSoP it may be academic and tangential but you're still wrong.
  • IMSoP
    IMSoP over 5 years
    @Jennifer Well, I'm not wrong that it's widely conjectured, even if people are wrong to conjecture it. And even if it's true that IBM invented the term, why did they choose those words? Did they write the name out longhand and then say "oh, that's a coincidence, it spells an English word" - or is it more likely they were looking for a term that seemed appropriate for the functionality, and thought that "spooling the jobs onto the tape" was a good image?
  • TemporalWolf
    TemporalWolf over 5 years
    This post would benefit greatly from citations, in particular for it's etymological claims.
  • gokhan acar
    gokhan acar over 5 years
    +1 Never knew where the term "spool" came from.
  • Tim
    Tim over 5 years
    Thanks. (1) "A print spool is effectively a buffer". Is the spool buffer in memory? (2) I also learned that OS creates a spool file for each print job. Are spool files residing on the spool "buffer" or on a disk?
  • Tim
    Tim over 5 years
    "Removing the spool on your computer might not have the desired result though since the printer itself could spool too!" If the printer also have its own spool, then why might removing the spool on my computer not have desired results? I guess after removing spool on my computer, double spooling becomes single spooling by the printer only?
  • Stephen Kitt
    Stephen Kitt over 5 years
    Print spools are typically stored on disk, wherever the print server is hosted. When I say printers can also have their own spool, this is normally the case for “networked” printers (which are connected to a network, rather than to a specific computer); they host their own print server(s) and have to manage multiple incoming jobs (which they do by having their own spool). When a printer has its own spool, it can accept print jobs much faster than they can be printed, so even if lpr waited for the printer to finish accepting the job, there would still be lag before it was fully processed.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix over 5 years
    I like the answer but the last paragraph referencing the spool of thread could probably be dropped without loosing meaning.
  • Fabby
    Fabby almost 5 years
    @Joe Same reason kids nowadays don't know what the save button actually means as they've never seen a Diskette / Floppy / Stiffy / ... >:-)