SlideShare a Scribd company logo
THREADS
(OPERATING SYSTEM)
Presented By : Prakhar Maurya
B.Sc. IT (3rd Semester)
@PRAKHAR
What is Thread ?
A thread is a flow of execution through the
process code, with its own program counter,
system registers and stack. A thread is also
called a light weight process. Threads provide a
way to improve application performance
through parallelism.
Each thread belongs to exactly one process
and no thread can exist outside a process.
@PRAKHAR
Single threaded Process and Multi-threaded Process
@PRAKHAR
Difference between Process and Threads :
S.N. Process Threads
1. Process is heavy weight or
resource intensive.
Thread is light weight taking lesser
resources than a process.
2. Process switching needs
interaction with operating system.
Thread switching does not need to
interact with operating system.
3. In multiple processing
environments each process
executes the same code but has its
own memory and file resources.
All threads can share same set of
open files, child processes.
4. If one process is blocked then no
other process can execute until the
first process is unblocked.
While one thread is blocked and
waiting, second thread in the same
task can run.
5. Multiple processes without using
threads use more resources.
Multiple threaded processes use
fewer resources.
6. In multiple processes each process
operates independently of the
others.
One thread can read, write or
change another thread's data.
@PRAKHAR
Advantages of Threads :
• Thread minimizes context switching time.
• Use of threads provides concurrency within a process.
• Efficient communication.
• Economy- It is more economical to create and context switch
threads.
• Utilization of multiprocessor architectures to a greater scale and
efficiency.
@PRAKHAR
Disadvantages of Threads :
• Blocking of parent threads will stop all child thread.
• Security.
@PRAKHAR
Types of Threads :
Threads are implemented in following two
ways :
• User Level Threads (ULT)
• Kernel Level Threads (KLT)
@PRAKHAR
User Level Threads (ULT) :
User level thread implement in user level
libraries, so thread switching does not need
to call operating system and to cause
interrupt to the kernel.
In fact, the kernel knows nothing about
user level threads and manages them as if
they were single-threaded process.
@PRAKHAR
Advantages of ULT :
• User level threads does not require modification to operating
system.
• Easy to represent and manage.
• User level thread can run on any operating system.
• User level threads are fast and efficient.
Disadvantages of ULT :
• There is a lack of coordination between threads and operating
system kernel.
• ULT require non-blocking system call (i.e. Multithreaded kernel)
@PRAKHAR
Kernel Level Threads (KLT) :
In this method, the kernel knows about
and manages the threads. No runtime
system is needed in this case. Operating
system kernel provides system call to
create and manage threads.
@PRAKHAR
Advantages of KLT :
• Kernel can simultaneously schedule multiple threads from the
same process on multiple processes.
• If one thread in a process is blocked the kernel can schedule
another thread of the same process.
• Kernel routines themselves can multithreaded.
Disadvantages of KLT :
• Kernel thread are generally slower to create and manage than the
user threads.
• Kernel requires Thread Control Block (TCB) for each thread in the
pool, hence complexity increases.
@PRAKHAR
Difference between ULT and KLT :
S.N. User Level Thread Kernel Level Thread
1. User level thread are faster to
create and manage.
Kernel level thread are slower to
create and manage.
2. Implementation is by a thread
library at the user level.
Operating system supports
creation of kernel level threads.
3. ULT is generic and can run on any
operating system.
KLT is specific to the operating
system.
4. Multi-Threaded can not take
advantages of multiprocessing.
Kernel routines themselves can be
multithreaded.
@PRAKHAR
Multi-Threading Models :
Some operating system provides a combined user
level thread and kernel level thread facility. Solaris
is a good example of this combined approch.
Multi-Threading models are three types.
• Many-to-One Model
• One-to-One Model
• Many-to-Many Model
@PRAKHAR
Many-to-One Model :
Implementation of the many-to-one
model (many user level thread to
one kernel level thread) allow the
application to create any number of
threads that can execute
concurrently. In this implementation,
all threads activity is restricted to
user space.
Additionally only one thread can
access the kernel at a time, so only
one schedulable entity is known to
the os.
@PRAKHAR
One-to-One Model :
The one-to-one model (one user
level thread to one kernel level
thread) is among the earliest
implementations of true
multithreading. In this
implementation, each ULT created
by the application is known to the
kernel,and all threads ca access the
kernel at the same time.
@PRAKHAR
Many-to-Many Model :
The many-to-many model (many
user level thread to many kernel
level thread) avoids many of the
limitations of the one-to-one model,
while extending multithreading
capabilities even further. The many-
to-many model also called two-level
model, minimize programing effort
while reducing the cost and weight
of each thread.
@PRAKHAR
“ THANK YOU !
@PRAKHAR

More Related Content

What's hot

Process of operating system
Process of operating systemProcess of operating system
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Riya Choudhary
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
Luis Goldster
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
meet darji
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
Venkata Sreeram
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
priyadeosarkar91
 
Kernel (OS)
Kernel (OS)Kernel (OS)
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
Mukesh Chinta
 
Multithreading
Multithreading Multithreading
Multithreading
WafaQKhan
 
Multithreading
MultithreadingMultithreading
Multithreading
A B Shinde
 
Virtual machine
Virtual machineVirtual machine
Virtual machine
Nikunj Dhameliya
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
Mukesh Chinta
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
NEERAJ BAGHEL
 
Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1
abhinav baba
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
Ravi Kumar Patel
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processesmyrajendra
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
Mukesh Chinta
 

What's hot (20)

Process of operating system
Process of operating systemProcess of operating system
Process of operating system
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Memory management
Memory managementMemory management
Memory management
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Multithreading
Multithreading Multithreading
Multithreading
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Virtual machine
Virtual machineVirtual machine
Virtual machine
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processes
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 

Viewers also liked

Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-GalvinSonali Chauhan
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
sgpraju
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
Ahmar Hashmi
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
Dr. Loganathan R
 
Process Scheduling
Process SchedulingProcess Scheduling
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Deepika Balichwal
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Prasunjeet Soni
 
Inter process communication
Inter process communicationInter process communication
Inter process communicationMohd Tousif
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
Abhishek Nagar
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess Communication
Deepak H L
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
RJ Mehul Gadhiya
 

Viewers also liked (12)

Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess Communication
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 

Similar to Threads (operating System)

threads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxthreads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptx
piyushlohia1857
 
Threads ppt
Threads pptThreads ppt
Threads ppt
panchaldev1
 
Thread
ThreadThread
Thread
ThreadThread
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
AnyapuPranav
 
Networking threads
Networking threadsNetworking threads
Networking threads
Nilesh Pawar
 
Lecture 3 threads
Lecture 3   threadsLecture 3   threads
Lecture 3 threads
Kumbirai Junior Muzavazi
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
bleh23
 
THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid
noman zahid
 
Thread
ThreadThread
Thread
sajidhuseyin
 
Thread
ThreadThread
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
BalasundaramSr
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
Kanza batool
 
Threads
ThreadsThreads
Threads
Shivam Singh
 
Threads
ThreadsThreads
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
kiran Patel
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptx
YojanaFegade
 
process and thread.pptx
process and thread.pptxprocess and thread.pptx
process and thread.pptx
HamzaxTv
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdf
Harika Pudugosula
 

Similar to Threads (operating System) (20)

threads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxthreads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptx
 
Threads ppt
Threads pptThreads ppt
Threads ppt
 
Thread
ThreadThread
Thread
 
Thread
ThreadThread
Thread
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
Lecture 3 threads
Lecture 3   threadsLecture 3   threads
Lecture 3 threads
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid
 
Thread
ThreadThread
Thread
 
Thread
ThreadThread
Thread
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
 
Threads
ThreadsThreads
Threads
 
Threads
ThreadsThreads
Threads
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptx
 
process and thread.pptx
process and thread.pptxprocess and thread.pptx
process and thread.pptx
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdf
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Threads (operating System)

  • 1. THREADS (OPERATING SYSTEM) Presented By : Prakhar Maurya B.Sc. IT (3rd Semester) @PRAKHAR
  • 2. What is Thread ? A thread is a flow of execution through the process code, with its own program counter, system registers and stack. A thread is also called a light weight process. Threads provide a way to improve application performance through parallelism. Each thread belongs to exactly one process and no thread can exist outside a process. @PRAKHAR
  • 3. Single threaded Process and Multi-threaded Process @PRAKHAR
  • 4. Difference between Process and Threads : S.N. Process Threads 1. Process is heavy weight or resource intensive. Thread is light weight taking lesser resources than a process. 2. Process switching needs interaction with operating system. Thread switching does not need to interact with operating system. 3. In multiple processing environments each process executes the same code but has its own memory and file resources. All threads can share same set of open files, child processes. 4. If one process is blocked then no other process can execute until the first process is unblocked. While one thread is blocked and waiting, second thread in the same task can run. 5. Multiple processes without using threads use more resources. Multiple threaded processes use fewer resources. 6. In multiple processes each process operates independently of the others. One thread can read, write or change another thread's data. @PRAKHAR
  • 5. Advantages of Threads : • Thread minimizes context switching time. • Use of threads provides concurrency within a process. • Efficient communication. • Economy- It is more economical to create and context switch threads. • Utilization of multiprocessor architectures to a greater scale and efficiency. @PRAKHAR
  • 6. Disadvantages of Threads : • Blocking of parent threads will stop all child thread. • Security. @PRAKHAR
  • 7. Types of Threads : Threads are implemented in following two ways : • User Level Threads (ULT) • Kernel Level Threads (KLT) @PRAKHAR
  • 8. User Level Threads (ULT) : User level thread implement in user level libraries, so thread switching does not need to call operating system and to cause interrupt to the kernel. In fact, the kernel knows nothing about user level threads and manages them as if they were single-threaded process. @PRAKHAR
  • 9. Advantages of ULT : • User level threads does not require modification to operating system. • Easy to represent and manage. • User level thread can run on any operating system. • User level threads are fast and efficient. Disadvantages of ULT : • There is a lack of coordination between threads and operating system kernel. • ULT require non-blocking system call (i.e. Multithreaded kernel) @PRAKHAR
  • 10. Kernel Level Threads (KLT) : In this method, the kernel knows about and manages the threads. No runtime system is needed in this case. Operating system kernel provides system call to create and manage threads. @PRAKHAR
  • 11. Advantages of KLT : • Kernel can simultaneously schedule multiple threads from the same process on multiple processes. • If one thread in a process is blocked the kernel can schedule another thread of the same process. • Kernel routines themselves can multithreaded. Disadvantages of KLT : • Kernel thread are generally slower to create and manage than the user threads. • Kernel requires Thread Control Block (TCB) for each thread in the pool, hence complexity increases. @PRAKHAR
  • 12. Difference between ULT and KLT : S.N. User Level Thread Kernel Level Thread 1. User level thread are faster to create and manage. Kernel level thread are slower to create and manage. 2. Implementation is by a thread library at the user level. Operating system supports creation of kernel level threads. 3. ULT is generic and can run on any operating system. KLT is specific to the operating system. 4. Multi-Threaded can not take advantages of multiprocessing. Kernel routines themselves can be multithreaded. @PRAKHAR
  • 13. Multi-Threading Models : Some operating system provides a combined user level thread and kernel level thread facility. Solaris is a good example of this combined approch. Multi-Threading models are three types. • Many-to-One Model • One-to-One Model • Many-to-Many Model @PRAKHAR
  • 14. Many-to-One Model : Implementation of the many-to-one model (many user level thread to one kernel level thread) allow the application to create any number of threads that can execute concurrently. In this implementation, all threads activity is restricted to user space. Additionally only one thread can access the kernel at a time, so only one schedulable entity is known to the os. @PRAKHAR
  • 15. One-to-One Model : The one-to-one model (one user level thread to one kernel level thread) is among the earliest implementations of true multithreading. In this implementation, each ULT created by the application is known to the kernel,and all threads ca access the kernel at the same time. @PRAKHAR
  • 16. Many-to-Many Model : The many-to-many model (many user level thread to many kernel level thread) avoids many of the limitations of the one-to-one model, while extending multithreading capabilities even further. The many- to-many model also called two-level model, minimize programing effort while reducing the cost and weight of each thread. @PRAKHAR
  • 17. “ THANK YOU ! @PRAKHAR