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

Submitted By Shamsa kanwal

Submitted to: Dr.Jabber


Roll no: 17
Semester: 2nd
Date: 13-12-2023
Subject: Operating system
Assignment 02
Contents
Threads: ....................................................................................................................................................... 3
Benefits of threaded: .................................................................................................................................... 4
Responsiveness: ....................................................................................................................................... 4
Resource sharing: ..................................................................................................................................... 4
Economy: ................................................................................................................................................. 5
Scalability: ............................................................................................................................................... 5
Multi-threading models: .............................................................................................................................. 5
Many-to-One Model: ............................................................................................................................... 5
One-to-One Model: .................................................................................................................................. 5
Many-to-Many Model: ............................................................................................................................ 6
Question no:01
Elaborate the term Threaded? What the benefits of threaded.
Explain the multi-threading models with the help of diagram.
Threads:
Thread is component of process or lightweight process within the program. Thread provides a
way to improve application performance through parallelism.
Each thread is comprises of:
 A thread ID
 A program counter
 A register set
 A Stack
A process can have multiple threads. If a process has many threads then it can share its code
section, data section and files.
Single thread process:

In the above diagram there is a process that has a single thread. Single thread means this process
can perform only one task at a time. Every thread has their own register, and stack. While he
code ,data and files are shared between the threads.
Multithreaded process:
In the multithreaded process the code, data section, and files belonging to this process are shared
by threads. While each thread has its separate register and stack. This process can perform
multiple tasks at a time because each thread perform different task. Multithreaded process is
much more efficient then single threaded process and it makes our computation faster and
efficient.

Benefits of threaded:
Responsiveness:
Multithreading allow a program to running if its part is blocked or performing lengthy operation.
For example in Web browsers we have different threads. One thread for displaying web page,
one thread for downloading, another thread for interaction with user. In this example different
threads are performing different tasks so if one thread is blocked the other task will continue to
perform.
Resource sharing:
In the multithreaded process the code section, data section, and files belonging to the same
process are shared by threads. Threads share the memory and the resources of the process to
which they belong by default. The benefit of sharing code and data is that it allows an
application to have several different threads of activity within the same address space.
Economy:
If there is no multithreading then we need to have separate process for every task. And we know
allocating memory and resource for process creation is costly. But in multithreaded process the
resources are shared we don’t need to have dedicated resources.
Scalability:
Scalability is a big advantage of multithreading threads can run concurrently on different
processors. Unlike single-threaded processes limited to one processor multithreading support
available processors for parallel task execution, enhancing overall efficiency and performance.
Multi-threading models:
Many-to-One Model:
The many-to-one model maps many user-level threads to one kernel thread. Thread management
is done by the thread library in user space.
Disadvantage:
 The entire process will block if a thread makes a block.
 Many-to-one model cannot run parallel
Implement:
 Green threads for Solaris
 GNU

One-to-One Model:
The one-to-one model maps each user thread to a kernel thread.
Advantage:
 It provides more concurrency than the many-to-one model.
 Efficient
 If a thread block other threads will continue to work.
Disadvantage:
 We cannot make as much kernel threads.
 Speed decrease if we make man kernel level threads.
Implement:
 Linux
 Window XP

Many-to-Many Model:
In many-to-many model user level threads are greater than kernel level threads.
Advantage:
 Parallel work
 Efficient
 No-block
Disadvantage:
 Context switching between threads can be expensive, especially on older hardware.
Implement:
 Solaris
 HP-UX

You might also like