0% found this document useful (0 votes)
43 views6 pages

System Software and Operating System 07 - Daily Class Notes

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 6

1

UGC NET

DAILY
CLASS NOTES
Computer

System Software and Operating System


Lecture – 7
Concept of Multithreading
2

Concept of Multithreading
Content:-
1. Threads
2. Multithreading models
3. User level thread vs kernel level thread

Threads:-
Basic CPU utilization unit is known as thread; it comprises a program counter, a thread ID, a stack and a register
set. It shares with other threads belonging to the same process/job its data section, code section, and other
operating- system resources, such as open files and signal. A traditional (or heavy weight) process/job has a single
thread of control.

Multithreaded models are run on many software packages that are used in modern desktop PCs. An application
typically is implemented as a separate process/job with several threads of control.

Single threaded process


Multi-threaded process
t
thread

Benefits of multithreaded programming can be broken down into four major categories:-
1. Responsiveness
2. Resource sharing
3. Economy
4. Scalability

Multicore Programming: A recent trend in the system design has been to place multiple computing cares on a
single chip, where each core is appears as a separate processor to the operating system. Multithreaded
programming provides the mechanism for more effective use of multiple cores and improved concurrency.
Five areas at present are challenges in programming for multicore systems:
3

1. Dividing Activity: This involves examining applications to find the area that can be divided into separate,
concurrent task and thus can run in parallel on individual cores.
2. Balance: while identifying tasks that can run in parallel, programmers must also ensure that the tasks perform
equal work to equal value.
3. Data Splitting: There is a separate core for accessing and manipulating the data as there are different
applications in which the tasks are divided.
4. Data Dependency: There must be examination of data dependency which is accessed by two or more tasks.
5. Testing and debugging: when the program is running in parallel on multi cores there are many different
execution paths. Testing and debugging such concurrent programs in inherently more difficult than testing
and debugging single- threaded application.

Multithreading Models
1. Many-to-One Model: The many-to-one model maps many user level threads to one kernel level thread.
Thread management is done by the thread library in user space, so it is efficient; but the entire process will be
block if a thread makes the blocking system call

2. One-to-One Model: In one-to-one model mapping of each user level thread to a kernel thread is done. The
only drawback to this model is that creating a user that requires creating the corresponding kernel thread.

3. Many-to-Many Model:- The many-to-many model multiplexes many user-level threads to a smaller or equal
number of kernel threads the number of kernel threads may be specific to either a particular applications or a
particular machine.
4

Note:- Kernel thread <= user Thread

User level threads vs kernel level thread

S. No. Parameters User Level Thread Kernel Level Thread

1. Implemented by User level threads are Kernel threads are implemented by


implemented by users. Operating System (OS).

2. Recognize The operating System doesn’t Kernel threads are recognized by


recognize user-level threads. Operating System.

3. Implementation Implementation of User threads Implementation of Kernel-Level thread is


is easy. complicated.

4. Context switch Context switch time is less. Context switch time is more.
time

5. Hardware support Context switch requires no Hardware support is needed.


hardware support.

6. Blocking operation If one user-level thread performs If one kernel thread performs a blocking
a blocking operation then the operation then another thread can continue
entire process will be blocked. execution.

7. Multithreading Multithread applications cannot Kernels can be multithreaded.


take advantage of
multiprocessing.

8. Creation and User-level threads can be Kernel-level level threads take more time
Management created and managed more to create and manage.
quickly.
5

S. No. Parameters User Level Thread Kernel Level Thread

9. Operating System Any operating system can Kernel-level threads are operating system-
support user-level threads. specific.

10. Thread The thread library contains the The application code does not contain
Management code for thread creation, thread management code. It is merely an
message passing, thread API to the kernel mode. The Windows
scheduling, data transfer, and operating system makes use of this
thread destroying feature.

11. Example Example: Java thread, POSIX Example: Window Solaris.


threads.

12. Advantages ● User Level Threads are ● Scheduling multiple threads that
simple and quick to create. belong to the same process on
● Can run on any operating different processors is possible in
system kernel-level threads.
● They perform better than ● Multithreading can be there for kernel
kernel threads since they routines.
don’t need to make system ● When a thread at the kernel level is
calls to create threads. halted, the kernel can schedule
● In user-level threads, another thread for the same process.
switching between threads
does not need kernel mode
privileges.

13. Disadvantages ● Multithreaded ● Transferring control within a process


application on user-level from one thread to another
threads cannot benefit from necessitates a mode switch to kernel
multiprocessing. mode.
● If a single user-level thread ● Kernel-level threads take more time to
performs a blocking create and manage than user-level
operation, the entire process threads.
is halted.

14. Memory In user-level threads, each In kernel-level threads have their own
management thread has its own stack, but stacks and their own separate address
they share the same address spaces, so they are better isolated from
space. each other.
6

S. No. Parameters User Level Thread Kernel Level Thread

15. Fault tolerance User-level threads are less fault- Kernel-level threads can be managed
tolerant than kernel-level independently, so if one thread crashes, it
threads. If a user-level thread doesn’t necessarily affect the others.
crashes, it can bring down the
entire process.

16. Resource User-level threads don’t take full It can access to the system-level features
utilization advantage of the system like I/O operations. So it can take full
resources, As they don’t have Advantages of System Resources.
direct access to the system-level
features like I/O operations

17. Portability User-level threads are more Kernel-level threads are less portable than
portable than kernel-level User-level threads.
threads.

PW Web/App : https://smart.link/7wwosivoicgd4
Library - https://smart.link/sdfez8ejd80if

You might also like