Threading model advantages and disadvantages

1. The user-level thread model advantages and disadvantages:

advantage:

Since thread scheduling is done at the user level, that is, compared to the kernel scheduler does not need to allow the CPU to switch between user mode and kernel mode, this implementation compared to the kernel-level threads can do very lightweight, the system consumption of resources will be much smaller, and therefore the cost of the number of threads that can be created with the context switch takes will be much smaller.

Disadvantages:

Concurrency can not do in the true sense, suppose a user threads on a certain process because a blocking call (such as I / O blocked) CPU to be interrupted (preemptive scheduling), then all in the process threads are blocked (because the thread scheduling from within a single user process is not CPU clock interrupt, so that no round robin scheduling), the entire process is suspended.

Weakness in the solution:

Many coroutine library will own some of the blocking operation to re-package fully non-blocking form, and then on the previous point to block, take the initiative to make their own, and some way to inform other users or wake up threads to be executed in KSE on the run, avoiding the kernel scheduler KSE obstruction due to do a context switch, so that the entire process will not be blocked.

2. kernel-level threading model advantages and disadvantages:

advantage:

Simple, directly by the operating system kernel thread and a scheduler, the CPU can quickly switch schedule threads, so can run multiple threads simultaneously, compared to the user-level threads model it truly parallel processing

Disadvantages:

As a direct aid of the operating system kernel to create, destroy and context between multiple threads as well as switching and scheduling, the resource costs rose sharply, and greatly affected the performance right.

3. The two threading model advantages and disadvantages:

advantage:

A two-threaded process model can be associated with multiple kernel threads KSE, which means multiple threads within a process can bind its own KSE respectively, similar to this point and kernel-level threads model; secondly, but also different from kernel-level threading model, it's a process where the thread is not unique to the KSE binding, but can be mapped to a plurality of user threads with KSE, KSE when a blocking operation because its binding thread is a kernel scheduler CPU when, in the course of the rest of its associated user threads can rebind operation and other KSE. So, two threading model is neither a user-level thread scheduling model that is not completely on their own kernel-level thread model relies entirely on the operating system scheduler, but rather an intermediate state (self-scheduling and dispatch systems work together).

Disadvantages:

The highly complex nature of this model. Operating system kernel developers generally do not use.

Released six original articles · won praise 1 · views 272

Guess you like

Origin blog.csdn.net/ALEX2205/article/details/104877544