Вы находитесь на странице: 1из 5

What is a Buffer in Operating System?

In computing, a buffer is a region of memory used to temporarily hold data while it is being moved from one
place to another. Typically, the data is stored in a buffer as it is retrieved from an input device (such as a
keyboard) or just before it is sent to an output device (such as a printer). However, a buffer may be used
when moving data between processes within a computer. This is comparable to buffers in
telecommunication. Buffers can be implemented in either hardware or software, but the vast majority of
buffers are implemented in software. Buffers are typically used when there is a difference between the rate
at which data is received and the rate at which it can be processed, or in the case that these rates are variable,
for example in a printer spooler.
A temporary storage area, usually in RAM. The purpose of most buffers is to act as a holding area, enabling
the CPU to manipulate data before transferring it to a device.
Because the processes of reading and writing data to a disk are relatively slow, many programs keep track of
data changes in a buffer and then copy the buffer to a disk. For example, word processors employ a buffer to
keep track of changes to files. Then when you save the file, the word processor updates the disk file with the
contents of the buffer. This is much more efficient than accessing the file on the disk each time you make a
change to the file.
Note that because your changes are initially stored in a buffer, not on the disk, all of them will be lost if the
computer fails during an editing session. For this reason, it is a good idea to save your file periodically. Most
word processors automatically save files at regular intervals.
Buffers are commonly used when burning data onto a compact disc, where the data is transferred to the
buffer before being written to the disc.
Another common use of buffers is for printing documents. When you enter a PRINT command, the
operating system copies your document to a print buffer (a free area in memory or on a disk) from which the
printer can draw characters at its own pace. This frees the computer to perform other tasks while the printer
is running in the background. Print buffering is called spooling.
Most keyboard drivers also contain a buffer so that you can edit typing mistakes before sending your
command to a program. Many operating systems, including DOS, also use a disk buffer to temporarily hold
data that they have read from a disk. The disk buffer is really a cache.
(v.) To move data into a temporary storage area.

From Wikipedia, the free encyclopedia


Jump to: navigation, search
This article needs additional citations for verification.
Please help improve this article by adding reliable references. Unsourced material may be challenged and
removed. (May 2009)
Not to be confused with page cache.
SCSI controller with disc buffer.
In computer storage, disk buffer (often ambiguously[citation needed] called disk cache or cache buffer[citation needed])
is the embedded memory in a hard drive acting as a buffer between the rest of the computer and the physical
hard disk platter that is used for storage. Modern hard disks come with 8 to 64 MiB of such memory.
Since the late 1980s, nearly all disks sold have embedded microcontrollers and either an ATA, Serial ATA,
SCSI, or Fibre Channel interface. The drive circuitry usually has a small amount of memory, used to store
the bits going to and coming from the disk platter.
The disk buffer is physically distinct from and is used differently than the page cache typically kept by the
operating system in the computer's main memory. The disk buffer is controlled by the microcontroller in the
hard disk drive, and the page cache is controlled by the computer to which that disk is attached. The disk
buffer is usually quite small, from 2 to 32 MiB, and the page cache is generally all unused physical memory.
While data in the page cache is reused multiple times, the data in the disk buffer is rarely reused.[citation needed]
In this sense, the terms disk cache and cache buffer are misnomers; the embedded controller's memory is
more appropriately called the disk buffer.[citation needed]
Note that disk array controllers, as opposed to disk controllers, usually have normal cache memory of
around 0.5–8 GiB.
Contents
1 Uses
1.1 Read-ahead/read-behind
1.2 Speed matching
1.3 Write acceleration
1.4 Command queuing
2 Performance
3 See also
4 References
Uses
Read-ahead/read-behind
When executing a read from the disk, the disk arm moves the read/write head to (or near) the correct track,
and after some settling time the read head begins to pick up bits. Usually, the first sectors to be read are not
the ones that have been requested by the operating system. The disk's embedded computer typically saves
these unrequested sectors in the disk buffer, in case the operating system requests them later.
Speed matching
The speed of the disk's I/O interface to the computer almost never matches the speed at which the bits are
transferred to and from the hard disk platter. The disk buffer is used so that both the I/O interface and the
disk read/write head can operate at full speed.
Write acceleration
The disk's embedded microcontroller may signal the main computer that a disk write is complete
immediately after receiving the write data, before the data are actually written to the platter. This early
signal allows the main computer to continue working even though the data has not actually been written yet.
This can be somewhat dangerous, because if power is lost before the data are permanently fixed in the
magnetic media, the data will be lost from the disk buffer, and the file system on the disk may be left in an
inconsistent state. On some disks, this vulnerable period between signaling the write complete and fixing the
data can be arbitrarily long, as the write can be deferred indefinitely by newly arriving requests. For this
reason, the use of write acceleration can be controversial. Consistency can be maintained, however, by using
a battery-backed memory system for caching data — although this is typically only found in high end RAID
controllers. Alternately, the caching can simply be turned off when the integrity of data is deemed more
important than write performance. Another option is to send data to disk in a carefully managed order and to
issue "cache flush" commands in the right places, like ZFS file system does.
Command queuing
Newer SATA and most SCSI disks can accept multiple commands while any one command is in operation
through "command queuing" (see NCQ and TCQ). These commands are stored by the disk's embedded
controller until they are completed. Should a read reference the data at the destination of a queued write, the
to-be-written data will be returned. Command queuing is different from write acceleration in that the main
computer's operating system is notified when data is actually written onto the magnetic media. The OS can
use this information to keep the file system consistent through rescheduled writes.
Performance
Where a buffer is large and the throughput of the disk is slow, the data becomes cached for too long,
resulting in degraded performance over equivalent disks with smaller buffers. This degradation occurs
because of longer latencies when flush commands are sent to a disk with a full buffer.

spooling
Last modified: Monday, October 14, 2002

Acronym for simultaneous peripheral operations on-line, spooling refers to putting jobs in a buffer, a
special area in memory or on a disk where a device can access them when it is ready. 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.
The most common spooling application is 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.

From Wikipedia, the free encyclopedia


Jump to: navigation, search
For use of this term to refer to thrust changes in jet engines, see Jet engine.
This article may require copy editing for grammar, style, cohesion, tone or spelling. You can
assist by editing it. (July 2009)
In computer science, spooling refers to a process of transferring data by placing it in a temporary working
area where another program may access it for processing at a later point in time. The normal English verb
"spool" can refer to the action of a storage device that incorporates a physical spool or reel, such as a tape
drive.
Spooling refers to copying files in parallel with other work. The most common use is in reading files used by
a job into or writing them from a buffer on a magnetic tape or a disk. 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.
This temporary working area would normally be a file or storage device. Usual uses of the term spooling
apply to situations where there is little or no direct communication between the program writing the data and
the program reading it. Spooling is often used when a device writes data faster than a target device can read
it, allowing the slower device to work at its own pace without requiring processing to wait for it to catch up.
Data is only modified through addition or deletion at the ends of the area, i.e., there is no random access or
editing.
The most common spooling application is print spooling: documents formatted for printing are stored onto a
buffer (usually an area on a disk) by a fast processor and retrieved and printed by a relatively slower printer
at its own rate. As soon as the fast processor has written the document to the spool device it has finished
with the job and is fully available for other processes. One or more processes may rapidly write several
documents to a print queue without waiting for each one to print before writing the next. Spooler or print
management software may allow priorities to be assigned to jobs, notify users when they have printed,
distribute jobs among several printers, allow stationery to be changed or select it automatically, generate
banner pages to identify and separate print jobs, etc.
The temporary storage area to which E-mail is delivered by a Mail Transfer Agent and in which it waits to
be picked up by a Mail User Agent is sometimes called a mail spool. Likewise, a storage area for Usenet
articles may be referred to as a news spool. (On Unix-like systems, these areas are usually located in the
/var/spool directory.) Unlike other spools, mail and news spools usually allow random access to
individual messages.
Contents
1 Origin of the term
2 The spooling mechanism
2.1 Behind the scenes
2.1.1 Without spooling
2.1.2 With spooling
2.2 In practice
3 See also
4 References
Origin of the term
This article does not cite any references or sources.
Please help improve this article by adding citations to reliable sources. Unsourced material may be
challenged and removed. (November 2008)
According to Tanenbaum, "Spool" is an acronym for simultaneous peripheral operations on-line[1] (though
others may consider this a backronym), or as for printers: simultaneous peripheral output on line. Early
mainframe computers had no disk drives and slightly more recent ones had, by current standards, small and
expensive hard disks.
In the late 1950's and early 1970's, computers used SPOOL software to copy card to tape, tape to card and
tape to printer, with occasional use for card-to-card copying. The introduction of the inexpensive IBM 1401
led to a temporary reduction in the use of SPOOL software.
In the latter 1960s and early 1970s, computers handled punch cards, and spooling systems such as HASP,
FIDO, PATCHES, [1], SHADOW & SHADOW II, Power, GRASP, and The Spooler found they could
benefit batch programs by spooling card input and output. (Some centers directed punch card and printed
output to tape for later processing. It has been suggested that the term 'spooling' may have derived from
these reels or 'spools' of tape, although the terms normally used for tape were reel or tape volume; this
etymology has not been sourced.)
The spooling mechanism
The entire key to spooling is asynchronous processing, where the program is not constrained by the speed of
slow devices, particularly printers.
Printers are relatively slow peripherals. In comparison, disc devices and particularly CPUs are orders of
magnitude faster. Without spooling print data, the speed of program operation is constrained by the slowest
device, commonly printers, forcing the program to wait for the mechanical motion of the printer.
Professionals say the program is 'print bound'.
For example, when a city prepares payroll checks, the actual computation may take a matter of minutes or
even seconds, but the printing process might take hours. If the program printed directly, computing
resources (CPU, memory, peripherals) would be tied up until the program was able to finish. The same is
true of personal computers. Without spooling, a word processor would be unable to continue until printing
finished. Without spooling, most programs would be relegated to patterns of fast processing and long waits,
an inefficient paradigm.
Magnetic recording tape wound onto a spool or reel.
Behind the scenes
A printing spooler contains two parts:
1. an operating system extension that traps data destined for a printer and buffers it,
2. a simple program that independently writes trapped data to the printer.
Without spooling
An application program may write print lines or pages intended for a slow physical printer. The operating
system receives I/O requests (input/output), including print lines or pages. Without a spooler, the OS allows
data to pass to the printer and the application program waits for completion before continuing.
With spooling
A spooling mechanism traps the I/O request, captures the output data, and releases the application to
continue processing. As the application continues, the spooler writes the data to a disc file and, if it's not
already running, it kicks off the other part of the spooler, the actual print routine. It reads the output lines
and writes them to the printer, independent of the original application which may have already ended...
In practice
Spooling improves the multiprogramming capability of systems. Most programs require input and produce
output. Without spooling, the number of tasks that could be multi-programmed might be limited by the
availability of peripherals; with spooling, a task doesn't need access to a real device.
Because disc drives are so much faster than printers, throughput radically improves by temporarily directing
printer output to disc storage and retrieving it at leisure.

Вам также может понравиться