Page 71 - DCAP103_Principle of operating system
P. 71
Principles of Operating Systems
Notes 3.1.3.1 Advantages
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. Some other advantages are:
• User-level threads does not require modification to operating systems.
• 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.
• Simple Management: This simply means that creating a thread, switching between threads
and synchronization between threads can all be done without intervention of the kernel.
• Fast and Efficient: Thread switching is not much more expensive than a procedure call.
3.1.3.2 Disadvantages
• There is a lack of coordination between threads and operating system kernel. Therefore,
process as whole gets one time slice irrespect of whether process has one thread or 1000
threads within. It is up to each thread to relinquish control to other threads.
• User-level threads require non-blocking systems call, i.e. a multithreaded kernel. Otherwise,
entire process will blocked in the kernel, even if there are runable threads left in the
processes. For example, if one thread causes a page fault, the process blocks.
3.1.4 Kernel-level Threads
In this method, the kernel knows about and manages the threads. No runtime system is needed
in this case. Instead of thread table in each process, the kernel has a thread table that keeps
track of all threads in the system. In addition, the kernel also maintains the traditional process
table to keep track of processes. Operating Systems kernel provides system call to create and
manage threads.
3.1.4.1 Advantages
• Because kernel has full knowledge of all threads, Scheduler may decide to give more time
to a process having large number of threads than process having small number of threads.
• Kernel-level threads are especially good for applications that frequently block.
3.1.4.2 Disadvantages
• The kernel-level threads are slow and inefficient. For instance, threads operations are
hundreds of times slower than that of user-level threads.
• 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 increased in kernel complexity.
3.1.5 Advantages of Threads over Multiple Processes
• Context Switching: Threads are very inexpensive to create and destroy, and they are
inexpensive to represent. For example, they require space to store, the PC, the SP, and the
general-purpose registers, but they do not require space to share memory information,
information about open files of I/O devices in use, etc. With so little context, it is much
faster to switch between threads. In other words, it is relatively easier for a context switch
using threads.
• Sharing: Threads allow the sharing of a lot resources that cannot be shared in process, for
example, sharing code section, data section, Operating System resources like open file, etc.
64 LOVELY PROFESSIONAL UNIVERSITY