Day 75 - Multithreading Models

As mentioned in the last post about threads, Multithreading is the ability of the CPU to run multiple threads of execution at the same time while sharing resources of a single or multiple cores. Threads are of mainly two levels, user threads and kernel threads.

User threads are supported above the kernel and are managed without the help from the kernel and kernel threads are directly supported by the Operating System. A relationship must exist between user threads and kernel threads. There are maily three types of realtions used in user-kernel threading model. These are following.

  • Many-to-One Model
  • One-to-One Model
  • Many-to-Many Model

Many-to-One Model

Many-to-One model maps many user-level threads to a single kernel-level threads. It is done in the user space by the thread library. In Many-to-One model if a thread makes a system blocking call it will block entire process. Only one thread can access the kernel at a time which makes it unable for multi threads to run in parallel on multiprocessors.

Many To One Multi-threading Model

One-to-One Model

One-to-One model maps each user thread to a single kernel thread. This way other threads can keep runnig while one thread is asking for a blocking system call. It also allows multiple threads to run in parallel on multiprocessors.

The drawback to this model is that running one user thread requires one kernel thread to run with it which can cause a burden on the system.

One To One Multi-threading Model

Many-to-Many Model

Many-to-Many model maps many user-level threads to less or equal number of kernle threads.The number of threads may be specific to an application or to a particular machine.

Many To Many Multi-threading Model


zainscizainsci