SlideShare a Scribd company logo
1 of 16
THREADS
(OPERATING SYSTEM)
Presented By : Piyush Lohia
B.Sc. (DVIT)
@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.
Types of Threads :
Threads are implemented in following two
ways :
• User Level Threads (ULT)
• Kernel Level Threads (KLT)
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.
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.
Disadvantages of ULT :
• There is a lack of coordination between threads and operating
system kernel.
• Lower performance: User-level threads rely on the application to
manage thread scheduling, which can be less efficient than kernel-
level thread scheduling
• Limited parallelism: User-level threads are limited to a single
processor, as the application has no control over thread scheduling
on other processors
Kernel Level Threads (KLT) :
In this method, the operating system
directly supports threads as part of the
kernel. Each thread is a separate entity
that can be scheduled and executed
independently by the operating system 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.
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.
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
Many-to-One Model :
In this model, we have multiple user
threads mapped to one kernel
thread. In this model when a user
thread makes a blocking system call
entire process blocks. As we have
only one kernel thread and only one
user thread can access kernel at a
time, so multiple threads are not
able access multiprocessor at the
same time. The thread management
is done on the user level so it is more
efficient.
One-to-One Model :
◦In this model, one to one
relationship between kernel and
user thread. In this model multiple
thread can run on multiple
processor. Problem with this model
is that creating a user thread
requires the corresponding kernel
thread.
◦As each user thread is connected to
different kernel , if any user thread
makes a blocking system call, the
other user threads won’t be blocked.
@PRAKHAR
Many-to-Many Model :
In this model, we have multiple user
threads multiplex to same or lesser
number of kernel level threads.
Number of kernel level threads are
specific to the machine, advantage
of this model is if a user thread is
blocked we can schedule others user
thread to other kernel thread. Thus,
System doesn’t block if a particular
thread is blocked. It is the best multi
threading model.
@PRAKHAR
“ THANK YOU !

More Related Content

Similar to threads-ppfldkgsh;reghuiregiuhrughet.pptx

Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programmingAnyapuPranav
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)kiran Patel
 
Operating system 20 threads
Operating system 20 threadsOperating system 20 threads
Operating system 20 threadsVaibhav Khanna
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcbKanza batool
 
Networking threads
Networking threadsNetworking threads
Networking threadsNilesh Pawar
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptxYojanaFegade
 
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 IN OPERATING SYSTEM BIKASH.pptx
THREADS IN OPERATING SYSTEM BIKASH.pptxTHREADS IN OPERATING SYSTEM BIKASH.pptx
THREADS IN OPERATING SYSTEM BIKASH.pptxDevishreeRout
 
Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)WajeehaBaig
 
chapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptchapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptaakarshsiwani1
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptxNagaVarthini
 

Similar to threads-ppfldkgsh;reghuiregiuhrughet.pptx (20)

Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Thread
ThreadThread
Thread
 
Thread
ThreadThread
Thread
 
Threads
ThreadsThreads
Threads
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
 
Operating system 20 threads
Operating system 20 threadsOperating system 20 threads
Operating system 20 threads
 
Concept of thread, multi thread, tcb
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Threads
ThreadsThreads
Threads
 
Threads.ppt
Threads.pptThreads.ppt
Threads.ppt
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptx
 
Threads
ThreadsThreads
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 ..
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Lecutur24 25
Lecutur24 25Lecutur24 25
Lecutur24 25
 
THREADS IN OPERATING SYSTEM BIKASH.pptx
THREADS IN OPERATING SYSTEM BIKASH.pptxTHREADS IN OPERATING SYSTEM BIKASH.pptx
THREADS IN OPERATING SYSTEM BIKASH.pptx
 
Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)
 
chapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptchapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.ppt
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptx
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

threads-ppfldkgsh;reghuiregiuhrughet.pptx

  • 1. THREADS (OPERATING SYSTEM) Presented By : Piyush Lohia B.Sc. (DVIT) @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.
  • 7. Types of Threads : Threads are implemented in following two ways : • User Level Threads (ULT) • Kernel Level Threads (KLT)
  • 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.
  • 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. Disadvantages of ULT : • There is a lack of coordination between threads and operating system kernel. • Lower performance: User-level threads rely on the application to manage thread scheduling, which can be less efficient than kernel- level thread scheduling • Limited parallelism: User-level threads are limited to a single processor, as the application has no control over thread scheduling on other processors
  • 10. Kernel Level Threads (KLT) : In this method, the operating system directly supports threads as part of the kernel. Each thread is a separate entity that can be scheduled and executed independently by the operating system 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.
  • 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.
  • 12. 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
  • 13. Many-to-One Model : In this model, we have multiple user threads mapped to one kernel thread. In this model when a user thread makes a blocking system call entire process blocks. As we have only one kernel thread and only one user thread can access kernel at a time, so multiple threads are not able access multiprocessor at the same time. The thread management is done on the user level so it is more efficient.
  • 14. One-to-One Model : ◦In this model, one to one relationship between kernel and user thread. In this model multiple thread can run on multiple processor. Problem with this model is that creating a user thread requires the corresponding kernel thread. ◦As each user thread is connected to different kernel , if any user thread makes a blocking system call, the other user threads won’t be blocked. @PRAKHAR
  • 15. Many-to-Many Model : In this model, we have multiple user threads multiplex to same or lesser number of kernel level threads. Number of kernel level threads are specific to the machine, advantage of this model is if a user thread is blocked we can schedule others user thread to other kernel thread. Thus, System doesn’t block if a particular thread is blocked. It is the best multi threading model. @PRAKHAR