资源按进程分配,调度以线程为基本单位。
There are two supporting levels for multithreading:
User Threads
Thread management done by user-level threads library.
Three primary thread libraries:
Kernel Threads
Supported by the Kernel
Examples
Note: No One-to-Many Model exists
Many user-level threads mapped to single kernel thread.
Used on systems that do not support kernel threads.
Each user-level thread maps to kernel thread.
Allows many user level threads to be mapped to many kernel threads.
Allows the operating system to create a sufficient number of kernel threads.
One popular variation on the many-to-many model still multiplexes many user-level threads to a smaller or equal number of kernel threads but also allows a user-level thread to be bound to a kernel thread. This variation, sometimes referred to as the two-level model, is supported by operating systems such as IRIX, HP-UX, and Tru64 UNIX.
A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization
API specifies behavior of the thread library, implementation is up to development of the library
Common in UNIX operating systems (Solaris, Linux, Mac OS X)
Implements the one-to-one mapping
Each thread contains:
The register set, stacks, and private storage area are known as the context of the threads
Linux refers to them as tasks rather than threads.
Thread creation is done through clone()
system call.
clone()
allows a child task to share the address space of the parent task (process).
Java threads may be created by:
Java threads are managed by the JVM.