文档介绍:: .
Distributed Systters and memory, used for the execution of a series of
instructions (., processor context, state).
Process context: The minimal collection of values stored in
registers and memory, used for the execution of a thread (.,
thread context, but now also at least MMU register values).
4 / 36Processes Threads
Context Switching
Observations
1 Threads share the same address space. Thread context switching
can be done entirely independent of the operating system.
2 Process switching is generally more expensive as it involves
getting the OS in the loop, ., trapping to the kernel.
3 Creating and destroying threads is much cheaper than doing so
for processes.
5 / 36Processes Threads
Threads and Operating Systems
Main issue
Should an OS kernel provide threads, or should they be implemented as
user-level packages?
User-space solution
All operations can be completely handled within a single process ⇒
implementations can be extremely efficient.
All services provided by the kernel are done on behalf of the process in
which a thread resides ⇒ if the kernel decides to block a thread, the
entire process will be blocked.
Threads are used when there are lots of external events: threads block
on a per-event basis ⇒ if the kernel can’t distinguish threads, how can it
support signaling events to them?
6 / 36Processes Threads
Threads and Operating Systems
Kernel solution
The whole idea is to have the kernel contain the implementation of a thread
package. This means that all operations return as system calls
Operat