What are the mappings of user to kernel?
What is a one-to-one mapping? a many-to-one mapping? a many-to-many mapping?
What are these user/kernel mappings? What impact does 开发者_开发问答it have on the system?
Many-to-one maps many user-level threads to one kernel thread. One-to-one maps one user-level thread to one kernel thread. Many-to-many maps many user-level threads to many kernel threads.
Many-to-one is managed by a thread library in user space and so it is efficient; but the entire process will block if a thread makes a blocking system call. Also since only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multiprocessors.
One-to-one provides more concurrency that the many-to-one model by allowing another thread to run when making a blocking system call; it also allows multiple threads to run on multiprocessors. The only drawback to this model is that creating user threads requires creating corresponding kernel threads, because creating many kernel threads can overburden the system most implementations limit the number of kernel threads that can be created.
Many-to-many is the rarest of the implementations and it multiplexes many user-level threads to many kernel threads. In theory it should provide the best concurrency, but true concurrency is not gained because the kernel can only schedule one thread at a time. Developers can create as many user threads as necessary and the corresponding kernel threads can run in parallel on the processor. Also, when preforming a blocking call the kernel can schedule another thread for execution.
From my notes in OS class as an answer for an assignment. i hope it helps.
Many-to-one
Since all the thread control structures exist within a single process’s addressable memory, switching between threads does not require a context switch, and is thus fast.
They can be more flexible than kernel-thread based implementations, since they give the application level programmer the ability to control thread scheduling. The programmer may have more knowledge about the behavior of the application and can thus schedule the threads more efficiently than an OS-kernel can.
One-to-one
In this model, the OS is aware of each thread and can schedule another if a particular thread blocks. The OS is unable to do this in the many-to-one model.
Multiple threads can execute in parallel on multiprocessor systems.
Many-to-many
As in the one-to-one model, the OS is aware of each thread and can schedule another if a particular thread blocks.
A danger of the one-to-one model is that if too many threads are created, the overhead of process/thread creation, process/thread destruction and context switching may outweigh any concurrency benefits of threading. The many-to-many model frees the application programmer from worrying about any such constraints on the number of threads. When creating a threaded application, the programmer simply creates as many threads as are needed, and the OS then distributes them amongst some smaller number of processes according to its own criteria.
As a reference check this out
精彩评论