SlideShare a Scribd company logo
1 of 21
Vadodara Institute Of Engineering
Operating system (2140702)
Created by :
Dharini vaghela
Content
 Introduction to thread
 Advantages of thread
 Types of thread
 user level threa
 kernel level thread
Thread
 A thread is a flow of execution through the process code, with its own
program counter that keeps track of which instruction to execute next,
system registers which hold its current working variables, and a stack
which contains the execution history.
 A thread shares with its peer threads few information like code
segment, data segment and open files. When one thread alters a code
segment memory item, all other threads see that.
 A thread is also called a lightweight process. Threads provide a way to
improve application performance through parallelism.
 Threads represent a software approach to improving performance of
operating system by reducing the overhead thread is equivalent to a
classical process.
 Each thread belongs to exactly one process and no thread can exist
outside a process.
 Each thread represents a separate flow of control.
 Threads have been successfully used in implementing network servers
and web server.
 They also provide a suitable foundation for parallel execution of
applications on shared memory multiprocessors.
 The following figure shows the working of a single-threaded and a
multithreaded process.
Advantages of Thread
 Threads minimize the context switching time.
 Use of threads provides concurrency within a process.
 Efficient communication.
 It is more economical to create and context switch threads.
 Threads allow utilization of multiprocessor architectures to a
greater scale and efficiency.
Types of Thread
Threads are implemented in following two ways −
1) User Level Threads − User managed threads.
2) Kernel Level Threads − Operating System managed threads acting
on kernel, an operating system core.
User Level Threads
 In this case, the thread management kernel is not aware of the existence
of threads.
 The thread library contains code for creating and destroying threads, for
passing message and data between threads, for scheduling thread
execution and for saving and restoring thread contexts.
 The application starts with a single thread.
Advantages
Thread switching does not require Kernel mode privileges.
User level thread can run on any operating system.
Scheduling can be application specific in the user level thread.
User level threads are fast to create and manage.
Disadvantages
In a typical operating system, most system calls are blocking.
Multithreaded application cannot take advantage of multiprocessing.
Kernel Level Threads
 Kernel threads are supported directly by the operating system.
 Any application can be programmed to be multithreaded. All of the
threads within an application are supported within a single process.
 The Kernel maintains context information for the process as a whole and
for individuals threads within the process.
 Scheduling by the Kernel is done on a thread basis. The Kernel performs
thread creation, scheduling and management in Kernel space.
 Kernel threads are generally slower to create and manage than the user
threads.
Advantages
 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 be multithreaded.
Disadvantages
 Kernel threads are generally slower to create and manage than the
user threads.
 Transfer of control from one thread to another within the same
process requires a mode switch to the Kernel.
User-Level Threads Kernel-Level Thread
1
User-level threads are faster to create and
manage.
Kernel-level threads are slower to create
and manage.
2
Implementation is by a thread library at the
user level.
Operating system supports creation of
Kernel threads.
3
User-level thread is generic and can run on
any operating system.
Kernel-level thread is specific to the
operating system.
4
Multi-threaded applications cannot take
advantage of multiprocessing.
Kernel routines themselves can be
multithreaded.
Difference between User-Level & Kernel-Level Thread
Multithreading Models
 Some operating system provide a combined user level thread and
Kernel level thread facility.
 Ex .Solaris
 In a combined system, multiple threads within the same application can
run in parallel on multiple processors and a blocking system call need
not block the entire process.
 Multithreading models are three types
1.Many to many relationship
2.Many to one relationship
3.One to one relationship
Many to Many Model
 The many-to-many model multiplexes any number of user threads onto
an equal or smaller number of kernel threads.
 In this model, developers can create as many user threads as necessary
and the corresponding Kernel threads can run in parallel on a
multiprocessor machine.
 This model provides the best accuracy on concurrency.
Many to Many Model
Many to One Model
 Many-to-one model maps many user level threads to one Kernel-level
thread.
 Thread management is done in user space by the thread library.
 When thread makes a blocking system call, the entire process will be
blocked.
 Only one thread can access the Kernel at a time, so multiple threads are
unable to run in parallel on multiprocessors.
Many to One Model
One to One Model
 There is one-to-one relationship of user-level thread to the kernel-level
thread.
 This model provides more concurrency than the many-to-one model.
 It also allows another thread to run when a thread makes a blocking
system call.
 It supports multiple threads to execute in parallel on microprocessors.
 Disadvantage of this model is that creating user thread requires the
corresponding Kernel thread.
 OS/2, windows NT and windows 2000 use one to one relationship model
One to One Model
Reference
 www.personal.kent.edu/~rmuhamma/OpSystems/Myos/threads.htm
 https://www.tutorialspoint.com/operating_system/os_multi_
threading.htm
 www.studytonight.com/operating-system/multithreading
 https://en.wikipedia.org/wiki/Thread_(computing)
Thread

More Related Content

What's hot

TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference ModelMukesh Tekwani
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processesmyrajendra
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming modeleasy notes
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Requirement modeling
Requirement modelingRequirement modeling
Requirement modelingAbdul Basit
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computingVajira Thambawita
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating SystemsNitish Gulati
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing ModelAdlin Jeena
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxLECO9
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering processDr. Loganathan R
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating systemudaya khanal
 

What's hot (20)

TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference Model
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processes
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming model
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Parallel Computing
Parallel ComputingParallel Computing
Parallel Computing
 
chapter 2 architecture
chapter 2 architecturechapter 2 architecture
chapter 2 architecture
 
Requirement modeling
Requirement modelingRequirement modeling
Requirement modeling
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Unit 1
Unit 1Unit 1
Unit 1
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
Parallel Programing Model
Parallel Programing ModelParallel Programing Model
Parallel Programing Model
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering process
 
Datalinklayer tanenbaum
Datalinklayer tanenbaumDatalinklayer tanenbaum
Datalinklayer tanenbaum
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Underlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computingUnderlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computing
 
5. protocol layering
5. protocol layering5. protocol layering
5. protocol layering
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 

Similar to Thread

Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programmingAnyapuPranav
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptxNagaVarthini
 
threads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxthreads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxpiyushlohia1857
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)kiran Patel
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcbKanza batool
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 
Networking threads
Networking threadsNetworking threads
Networking threadsNilesh Pawar
 
threads and its types ....in operating system ..
threads and its types ....in operating system ..threads and its types ....in operating system ..
threads and its types ....in operating system ..Nimrakhan89
 
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
 

Similar to Thread (20)

Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Thread
ThreadThread
Thread
 
Threads ppt
Threads pptThreads ppt
Threads ppt
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptx
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
threads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxthreads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptx
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
 
thread os.pptx
thread os.pptxthread os.pptx
thread os.pptx
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
threads and its types ....in operating system ..
threads and its types ....in operating system ..threads and its types ....in operating system ..
threads and its types ....in operating system ..
 
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
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Threads.ppt
Threads.pptThreads.ppt
Threads.ppt
 
Threads
ThreadsThreads
Threads
 
Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Threads
ThreadsThreads
Threads
 
W-9.pptx
W-9.pptxW-9.pptx
W-9.pptx
 

Recently uploaded

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Thread

  • 1. Vadodara Institute Of Engineering Operating system (2140702) Created by : Dharini vaghela
  • 2. Content  Introduction to thread  Advantages of thread  Types of thread  user level threa  kernel level thread
  • 3. Thread  A thread is a flow of execution through the process code, with its own program counter that keeps track of which instruction to execute next, system registers which hold its current working variables, and a stack which contains the execution history.  A thread shares with its peer threads few information like code segment, data segment and open files. When one thread alters a code segment memory item, all other threads see that.  A thread is also called a lightweight process. Threads provide a way to improve application performance through parallelism.
  • 4.  Threads represent a software approach to improving performance of operating system by reducing the overhead thread is equivalent to a classical process.  Each thread belongs to exactly one process and no thread can exist outside a process.  Each thread represents a separate flow of control.  Threads have been successfully used in implementing network servers and web server.  They also provide a suitable foundation for parallel execution of applications on shared memory multiprocessors.
  • 5.  The following figure shows the working of a single-threaded and a multithreaded process.
  • 6. Advantages of Thread  Threads minimize the context switching time.  Use of threads provides concurrency within a process.  Efficient communication.  It is more economical to create and context switch threads.  Threads allow utilization of multiprocessor architectures to a greater scale and efficiency.
  • 7. Types of Thread Threads are implemented in following two ways − 1) User Level Threads − User managed threads. 2) Kernel Level Threads − Operating System managed threads acting on kernel, an operating system core.
  • 8. User Level Threads  In this case, the thread management kernel is not aware of the existence of threads.  The thread library contains code for creating and destroying threads, for passing message and data between threads, for scheduling thread execution and for saving and restoring thread contexts.  The application starts with a single thread.
  • 9. Advantages Thread switching does not require Kernel mode privileges. User level thread can run on any operating system. Scheduling can be application specific in the user level thread. User level threads are fast to create and manage. Disadvantages In a typical operating system, most system calls are blocking. Multithreaded application cannot take advantage of multiprocessing.
  • 10. Kernel Level Threads  Kernel threads are supported directly by the operating system.  Any application can be programmed to be multithreaded. All of the threads within an application are supported within a single process.  The Kernel maintains context information for the process as a whole and for individuals threads within the process.  Scheduling by the Kernel is done on a thread basis. The Kernel performs thread creation, scheduling and management in Kernel space.  Kernel threads are generally slower to create and manage than the user threads.
  • 11. Advantages  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 be multithreaded. Disadvantages  Kernel threads are generally slower to create and manage than the user threads.  Transfer of control from one thread to another within the same process requires a mode switch to the Kernel.
  • 12. User-Level Threads Kernel-Level Thread 1 User-level threads are faster to create and manage. Kernel-level threads are slower to create and manage. 2 Implementation is by a thread library at the user level. Operating system supports creation of Kernel threads. 3 User-level thread is generic and can run on any operating system. Kernel-level thread is specific to the operating system. 4 Multi-threaded applications cannot take advantage of multiprocessing. Kernel routines themselves can be multithreaded. Difference between User-Level & Kernel-Level Thread
  • 13. Multithreading Models  Some operating system provide a combined user level thread and Kernel level thread facility.  Ex .Solaris  In a combined system, multiple threads within the same application can run in parallel on multiple processors and a blocking system call need not block the entire process.  Multithreading models are three types 1.Many to many relationship 2.Many to one relationship 3.One to one relationship
  • 14. Many to Many Model  The many-to-many model multiplexes any number of user threads onto an equal or smaller number of kernel threads.  In this model, developers can create as many user threads as necessary and the corresponding Kernel threads can run in parallel on a multiprocessor machine.  This model provides the best accuracy on concurrency.
  • 15. Many to Many Model
  • 16. Many to One Model  Many-to-one model maps many user level threads to one Kernel-level thread.  Thread management is done in user space by the thread library.  When thread makes a blocking system call, the entire process will be blocked.  Only one thread can access the Kernel at a time, so multiple threads are unable to run in parallel on multiprocessors.
  • 17. Many to One Model
  • 18. One to One Model  There is one-to-one relationship of user-level thread to the kernel-level thread.  This model provides more concurrency than the many-to-one model.  It also allows another thread to run when a thread makes a blocking system call.  It supports multiple threads to execute in parallel on microprocessors.  Disadvantage of this model is that creating user thread requires the corresponding Kernel thread.  OS/2, windows NT and windows 2000 use one to one relationship model
  • 19. One to One Model
  • 20. Reference  www.personal.kent.edu/~rmuhamma/OpSystems/Myos/threads.htm  https://www.tutorialspoint.com/operating_system/os_multi_ threading.htm  www.studytonight.com/operating-system/multithreading  https://en.wikipedia.org/wiki/Thread_(computing)