• Process switch: An operation that switches the processor from one process to
another, by saving all the process control data, registers, and other information
for the first and replacing them with the process information for the second.2
• Thread: A dispatchable unit of work within a process. It includes a processor
context (which includes the program counter and stack pointer) and its own
data area for a stack (to enable subroutine branching). A thread executes sequentially
and is interruptible so that the processor can turn to another thread.
• Thread switch: The act of switching processor control from one thread to another
within the same process.Typically, this type of switch is much less costly
than a process switch.
Thus, a thread is concerned with scheduling and execution, whereas a process
is concerned with both scheduling/execution and resource ownership. The multiple
threads within a process share the same resources. This is why a thread switch is
much less time consuming than a process switch.Traditional operating systems, such
as earlier versions of UNIX, did not support threads. Most modern operating systems,
such as Linux, other versions of UNIX, and Windows, do support thread. A
distinction is made between user-level threads, which are visible to the application
program, and kernel-level threads, which are visible only to the operating system.
Both of these may be referred to as explicit threads, defined in software.
All of the commercial processors and most of the experimental processors so
far have used explicit multithreading. These systems concurrently execute instructions
from different explicit threads, either by interleaving instructions from different
threads on shared pipelines or by parallel execution on parallel pipelines.
Implicit multithreading refers to the concurrent execution of multiple threads
extracted from a single sequential program. These implicit threads may be defined
either statically by the compiler or dynamically by the hardware. In the remainder
of this section we consider explicit multithreading.
Approaches to Explicit Multithreading
At minimum, a multithreaded processor must provide a separate program counter
for each thread of execution to be executed concurrently. The designs differ in the
amount and type of additional hardware used to support concurrent thread execution.
In general, instruction fetching takes place on a thread basis. The processor
treats each thread separately and may use a number of techniques for optimizing
single-thread execution, including branch prediction, register renaming, and superscalar
techniques.What is achieved is thread-level parallelism, which may provide
for greatly improved performance when married to instruction-level parallelism.
Broadly speaking, there are four principal approaches to multithreading:
• Interleaved multithreading: This is also known as fine-grained multithreading.
The processor deals with two or more thread contexts at a time, switching
from one thread to another at each clock cycle. If a thread is blocked because