Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Threading Models
Support for threads may be provided either at the user level, for user threads,
or by the kernel, for kernel threads. User threads are supported above the
kernel and are managed without kernel support, whereas kernel threads are
supported and managed directly by the operating system. Virtually all
contemporary operating systems including Windows, Linux, Mac OS X,
and Solaris support kernel threads. Ultimately, a relationship must exist
between user threads and kernel threads. In this section, we look at three
common ways of establishing such a relationship: the many-to-one model,
the one-to-one model, and the many-to- many model.
1.1
Many-to-One Model
1.2
One-to-One Model
The one-to-one model maps each user thread to a kernel thread. It provides more concurrency than the many-to-one model by allowing another
thread to run when a thread makes a blocking system call. It also allows
multiple threads to run in parallel on multiprocessors. The only drawback to
this model is that creating a user thread requires creating the corresponding
kernel thread. Because the overhead of creating kernel threads can burden
the performance of an application, most implementations of this model restrict the number of threads supported by the system. Linux, along with
the family of Windows operating systems, implement the one-to-one model.
1.3
Many-to-Many Model
JVM Threads
Linux Threads
Linux provides the fork() system call with the traditional functionality
of duplicating a process. Linux also provides the ability to create threads
using the clone() system call. However, Linux does not distinguish between
processes and threads. In fact, Linux uses the term task rather than
process or thread when referring to a flow of control within a program.
3