Sharing a single CPU
between multiple tasks (or "threads") in a way designed to minimise the time required to switch threads. This is accomplished by sharing as much as possible of the program execution environment between the different threads so that very little state needs to be saved and restored when changing thread.
Multithreading differs from multitasking
in that threads share more of their environment with each other than do tasks under multitasking. Threads may be distinguished only by the value of their program counters and stack pointers while sharing a single address space
and set of global variables. There is thus very little protection of one thread from another, in contrast to multitasking.
Multithreading can thus be used for very fine-grain multitasking, at the level of a few instructions, and so can hide latency
by keeping the processor busy after one thread issues a long-latency instruction on which subsequent instructions in that thread depend.
A light-weight process
is somewhere between a thread and a full process. TL0
is an example of a threaded machine language. Dataflow computation (E.g. Id
) is an extreme form of multithreading.