Information Technology Reference
In-Depth Information
navigation widgets, to construct the network messages needed to fetch
additional images from the distant servers, and to parse the reply mes-
sages that come back.
Performance: Coping with high-latency I/O devices. To do useful
work, computers must interact with the outside world via Input/Output
(I/O) devices. By running tasks as separate threads, when one task is
waiting for I/O, the processor can make progress on a different task.
We do not want the processor to be idle while waiting for I/O to complete
for two reasons.
First, processors are often much faster than the I/O systems with which
they interact, so it is useful for a programmer to multiplex the processor
among multiple tasks. For example, the latency to read from disk can be
tens of milliseconds, so after requesting a block from disk, an operating
system switches to doing other work until the disk has copied that block
to the machine's main memory.
Second, I/O provides a way for the computer to interact with external en-
tities like users pressing keys on a keyboard or a remote computer sending
network packets. The arrival of this type of I/O event is unpredictable,
so we want the processor to be able to work on other things while still
responding quickly to these events.
Example: Threads for I/O performance. In our Earth Visualizer ap-
plication, a snappy user interface is essential, but much of the imagery
is stored on remote servers and fetched by the application only when
needed. The application still provides a responsive experience when a
user changes location by simultaneously drawing a low-resolution view
of the new location while fetching higher-resolution images from the dis-
tant servers. The application then progressively updates the view as the
higher-resolution images arrive.
4.1.1
Threads: Definition and properties
Above, we sketched what a thread is, how it is used, and why it is useful. To
go further, we must define a thread and its properties more precisely.
A thread is a single execution sequence that represents a separately schedu-
Denition: thread
lable task.
Single execution sequence. By single execution sequence we mean that
each thread executes a sequence of instructions|assignments, condition-
als, loops, procedures, etc.|just as in the familiar programming model.
Separately schedulable task. By separately schedulable task we mean
that the operating system can run, suspend, or resume a thread at any
time.
Search WWH ::




Custom Search