Introduction to Operating Systems: Unit II(a): Process Management

Types of Threads

Process Management - Introduction to Operating Systems

All modern operating system support threading model. Implementation of thread will change according to the operating system.

Types of Thread

AU: Dec.-17

• Threads are of two types:

1. User level thread 

2. Kernel level thread

• All modern operating system support threading model. Implementation of thread will change according to the operating system.

User Level Thread

• User level thread uses user space for thread scheduling. These threads are transparent to the operating system. User level threads are created by runtime libraries that cannot execute privileged instructions.

User-level threads have low overhead but it can achieve high performance in computation. User-level threads are managed entirely by the run-time system. 

User-level threads are small and faster. A thread is simply represented by registers, stack and small thread control block.Fig. 2.8.1 shows User level thread.


• The code for creation and destroying thread, message passing and data transfer, thread scheduling is included into thread library. Kernel is unaware of user level thread.

• User level threads do not invoke the Kernel for scheduling decision.

• User level thread are also called many to one mapping thread because the operating system maps all threads in a multithreaded process to a single execution context. The operating system considers as each multithreaded processes as a single execution unit.

• Example: POSIX Pthreads and Mach C-threads.

Advantages:

1. Kernel mode privilege does not require for thread switching.

2. These threads are fast to create and manage.

3. User level thread works even if the OS does not support threads.

4. User level threads are more portable.

5. Threading library controls flow of thread.

Disadvantages:

1. If thread blocks, the Kernel may block the all threads.

2. Not suitable for multiprocessor system.

3. User level threads also do not support system wide scheduling priority.

Kernel Level Thread

• In Kernel level thread, thread management is done by Kernel. Operating systems support the Kernel level thread. Since Kernel managing threads,

• Kernel can schedule another thread if a given thread blocks rather than blocking the entire processes. Fig. 2.8.2 shows Kernel level thread.

• Kernel level thread support one to one thread mapping. This mapping requires each user thread with kernel thread. Operating system performs this mapping.

• Threads are constructed and controlled by system calls. The system knows the state of each thread.

• Thread management code is not included in the application code. It is only API to the Kernel thread. Windows operating system uses this facility.

Any application can be programmed to be multithreaded. All of the threads within an application are supported within a single process.

• Kernel performs scheduling on a thread basis. The Kernel support for scheduling and management, thread creation only in Kernel space.

• Kernel level threads are slower than user level threads.

Example: Windows 95/98/NT, Sun Solaris and Digital UNIX.

Advantages :

1. Each thread can be treated separately.

2. A thread blocking in the Kernel does not block all other threads in the same process.

3. Kernel routines itself as multithreaded.

Disadvantages:

1. Slower than the user level thread.

2. There will be overhead and increased in Kernel complexity.

Difference between User Level Thread and Kernel Level Thread

University Question

1. Write the difference between user thread and kernel thread.  AU: Dec.-17, Marks 5

Introduction to Operating Systems: Unit II(a): Process Management : Tag: : Process Management - Introduction to Operating Systems - Types of Threads