Types of Threads || Process and Thread Management || Bcis Notes

Types of Threads || Process and Thread Management || Bcis Notes

Types of Threads

The types of threads in process and thread management are described below:-

1. User Level Threads
• Thread management is done in userspace of main memory by a user-level thread library.
• The user-level or programmer takes the information from the thread library which contains the code about creation, destroy, schedule, execution and restoring of threads.
• The kernel doesn’t know about these threads
• User Level Threads are faster to create and manage

Advantages:
1. The most obvious advantage of this technique is that a user-level threads package can be implemented on an Operating System that does not support threads.
2. User-level threads do not require modification to operating systems.
3. Simple Representation: Each thread is represented simply by a PC, registers, stack and a small control block, all stored in the user process address space.
4. Simple Management: This simply means that creating a thread, switching between threads and synchronization between threads can all be done without the intervention of the kernel.
5. Fast and Efficient: Thread switching is not much more expensive than a procedure call.

Disadvantages:

1. User-Level threads are not a perfect solution as with everything else, they are a tradeoff. Since User-Level threads are invisible to the OS they are not well integrated with the OS. As a result, Os can make poor decisions like scheduling a process with idle threads, blocking a
process whose thread initiated an I/O even though the process has other threads that can run and unscheduling a process with a thread holding a lock. Solving this requires communication between kernel and user-level thread manager.
2. There is a lack of coordination between threads and the operating system kernel. Therefore, the process as a whole gets a one-time slice irrespective of whether a process has one thread or 1000 threads within. It is up to each thread to relinquish control to other threads.
3. User-level threads require non-blocking systems call i.e., a multithreaded kernel. Otherwise, the entire process will block in the kernel, even if there are runnable threads left in the processes. For example, if one thread causes a page fault, the process blocks.

2. Kernel Level Threads
• The thread that is defined and managed by a direct kernel of Operating system is kernel-level threads
• The kernel performs thread creation, scheduling, and management
• Kernel threads are used in the internal working of the operating system
• Kernel threads are slower to create and manage

Advantages:

1. Because kernel has full knowledge of all threads, Scheduler may decide to give more time to a process having a large number of threads than process having a small number of threads.
2. Kernel-level threads are especially good for applications that frequently block.

Disadvantages:

1. The kernel-level threads are slow and inefficient. For instance, threads operations are hundreds of times slower than that of user-level threads.
2. Since kernel must manage and schedule threads as well as processes. It requires a full thread control block (TCB) for each thread to maintain information about threads. As a result, there is significant overhead and an increase in kernel complexity.

you may also like Threads

Be the first to comment

Leave a Reply

Your email address will not be published.


*