Spooling and Buffering: Difference between revisions

From COMP15212 Wiki
gravatar Yuron [userbureaucratinterface-adminsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
m (1 revision imported)
pc>Yuron
No edit summary
Line 3: Line 3:


== Spooling ==
== Spooling ==
Spooling is a form of buffering typified by <strong>printer spooling</strong>.  A
Spooling is a form of buffering typified by <strong>printer spooling</strong>.  A printer is a slow device which is usually also a shared resource. Rather than provide a printer for every machine, ‘the printer’ can be a [[Virtualisation|virtual]] process.
printer is a slow device which is usually also a shared resource.
Rather than provide a printer for every machine, ‘the
printer’ can be a [[Virtualisation|virtual]] process.


The spooler accepts print jobs, ensuring the integrity of each.  These
The spooler accepts print jobs, ensuring the integrity of each.  These are [[Queues|queued]] – possibly including some priority ordering – and output, probably using a printer [[Daemons|Daemon]] or similar strategy.  (This is an everyday example of a <strong>batch</strong> scheduling job.)
are [[Queues|queued]] – possibly including some priority ordering –
and output, probably using a printer [[Daemons|Daemon]] or similar
strategy.  (This is an everyday example of a <strong>batch</strong> scheduling
job.)


[[Image:print_spooler.png|link=|alt=Print spooler]]
[[Image:print_spooler.png|link=|alt=Print spooler]]


A spooler can be used to add information, such as a header page
A spooler can be used to add information, such as a header page identifying who sent the job on printing, if desired.
identifying who sent the job on printing, if desired.


== Buffering ==
== Buffering ==
General buffering strategies are covered [[Queues|here]].  In I/O
General buffering strategies are covered [[Queues|here]].  In I/O buffering there are sometimes other requirements: one example is <strong>double buffering</strong>.
buffering there are sometimes other requirements: one example is
<strong>double buffering</strong>.


Imagine sending translating a serial I/O [[Streams|stream]] into a disk
Imagine sending translating a serial I/O [[Streams|stream]] into a disk output (which consists, necessarily, of <em>blocks</em>.  A block write can be initiated when a block buffer is full; that then takes some time, during which more characters may arrive … and have to go somewhere.
output (which consists, necessarily, of <em>blocks</em>.  A block write can
be initiated when a block buffer is full; that then takes some time,
during which more characters may arrive … and have to go somewhere.


A typical approach is to have a <em>double</em> buffer: fill one buffer then
A typical approach is to have a <em>double</em> buffer: fill one buffer then schedule that for writing whilst beginning to fill the other one.  As long as the block write is complete before the <em>second</em> buffer is full, nothing needs to stall.  When the second buffer is full the buffers can be swapped again and the process continue.
schedule that for writing whilst beginning to fill the other one.  As
long as the block write is complete before the <em>second</em> buffer is
full, nothing needs to stall.  When the second buffer is full the
buffers can be swapped again and the process continue.


[[Image:double_buffering.png|link=|alt=Double buffering]]
[[Image:double_buffering.png|link=|alt=Double buffering]]


Another example of double buffering occurs in animated video games.
Another example of double buffering occurs in animated video games. The screen being viewed is one buffer and needs to remain stable; another buffer will be being drawn concurrently (this is the time-consuming bit!).  When the second buffer is ready the two can be swapped and the ‘spare’ one cleared and recycled.
The screen being viewed is one buffer and needs to remain stable;
another buffer will be being drawn concurrently (this is the
time-consuming bit!).  When the second buffer is ready the two can be
swapped and the ‘spare’ one cleared and recycled.
<blockquote>
<blockquote>
In practice it is important in a video game that the frame buffer
In practice it is important in a video game that the frame buffer swaps happen at a constant rate and these are synchronised with the output which is maintaining the screen.  Thus the output rate will be an integer division of the output frame rate.  The buffer swap process will be triggered by an [[Interrupts|interrupt]] from the video driver and the drawing process has a [[Real_Time|hard real-time]] constraint to meet this. We thought you’d like to know.
swaps happen at a constant rate and these are synchronised with the
output which is maintaining the screen.  Thus the output rate will
be an integer division of the output frame rate.  The buffer swap
process will be triggered by an [[Interrupts|interrupt]] from the
video driver and the drawing process has a [[Real_Time|hard real-time]] constraint to meet this.
We thought you’d like to know.
</blockquote>
</blockquote>
----
----
 
{{BookChapter|12.4.1-12.4.4|508-511}}
{{PageGraph}}
{{PageGraph}}
{{Category|Concepts}}
{{Category|Concepts}}
{{Category|IO}}
{{Category|IO}}
{{Category|User}}
{{Category|User}}

Revision as of 13:38, 4 August 2019

Depends on Queues

Spooling

Spooling is a form of buffering typified by printer spooling. A printer is a slow device which is usually also a shared resource. Rather than provide a printer for every machine, ‘the printer’ can be a virtual process.

The spooler accepts print jobs, ensuring the integrity of each. These are queued – possibly including some priority ordering – and output, probably using a printer Daemon or similar strategy. (This is an everyday example of a batch scheduling job.)

Print spooler

A spooler can be used to add information, such as a header page identifying who sent the job on printing, if desired.

Buffering

General buffering strategies are covered here. In I/O buffering there are sometimes other requirements: one example is double buffering.

Imagine sending translating a serial I/O stream into a disk output (which consists, necessarily, of blocks. A block write can be initiated when a block buffer is full; that then takes some time, during which more characters may arrive … and have to go somewhere.

A typical approach is to have a double buffer: fill one buffer then schedule that for writing whilst beginning to fill the other one. As long as the block write is complete before the second buffer is full, nothing needs to stall. When the second buffer is full the buffers can be swapped again and the process continue.

Double buffering

Another example of double buffering occurs in animated video games. The screen being viewed is one buffer and needs to remain stable; another buffer will be being drawn concurrently (this is the time-consuming bit!). When the second buffer is ready the two can be swapped and the ‘spare’ one cleared and recycled.

In practice it is important in a video game that the frame buffer swaps happen at a constant rate and these are synchronised with the output which is maintaining the screen. Thus the output rate will be an integer division of the output frame rate. The buffer swap process will be triggered by an interrupt from the video driver and the drawing process has a hard real-time constraint to meet this. We thought you’d like to know.


Also refer to: Operating System Concepts, 10th Edition: Chapter 12.4.1-12.4.4, pages 508-511


Articles on Concepts
About this resource • Application Binary Interface (ABI) • Arrays • Atomicity • Boot • Cache • Cacheability • Caching • Concepts • Containers • Context • Context Switching • Deadlock • Direct Memory Access (DMA) • Environment Variables • Exceptions • File Attributes • Fragmentation • Hypervisor • Interrupts • Operation Ordering • PATH • Pointers • Process Scheduling • Processes • Processor Privilege • Queues • Real Time • Reentrancy • Relocatable Code • Spooling and Buffering • Synchronisation • Thrashing • Threads • Virtual Memory • Virtualisation
Articles on IO
Cacheability • Device Drivers • Direct Memory Access (DMA) • IO • Interprocess Communication • Interrupt Controller • Interrupt Service Routines (ISRs) • Interrupts • Libraries • Peripheral devices • Pipes • Queues • Queues Extra • Resources • Shell • Sockets • Spooling and Buffering • Starvation • Streams • System Calls • Thrashing • Timers • Using Peripherals • Virtualisation • Write Buffer
Articles on User
"Everything is a File" • Application Binary Interface (ABI) • Arrays • Boot • Buffer Overflow • Containers • Daemons • Disk Partition • Dynamic Memory Allocation • Emulator traps • Environment Variables • Errors • Exceptions • File Attributes • File Locking • File Permissions • Introduction to Operating Systems • Journalling File System • Links • Locks • Man(ual pages in Unix) • Memory Mapped Files • Monitoring • Network File System (NFS) • PATH • Pipes • Pointers • Relocatable Code • Reset • SETUID • Shell • Sockets • Spooling and Buffering • Streams • Structures • Superuser • System Calls • Unix Signals • User • Using Peripherals