SlideShare una empresa de Scribd logo
1 de 17
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

Más contenido relacionado

La actualidad más candente

Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
Piyush Rochwani
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 

La actualidad más candente (20)

DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Lecture 3 threads
Lecture 3   threadsLecture 3   threads
Lecture 3 threads
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Demand paging
Demand pagingDemand paging
Demand paging
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Architecture of operating system
Architecture of operating systemArchitecture of operating system
Architecture of operating system
 
BANKER'S ALGORITHM
BANKER'S ALGORITHMBANKER'S ALGORITHM
BANKER'S ALGORITHM
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
System calls
System callsSystem calls
System calls
 

Destacado

Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
Sonali Chauhan
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
Mohd Tousif
 

Destacado (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 a Threads (operating System)

OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
bleh23
 

Similar a 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
 
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
 
Operating system 20 threads
Operating system 20 threadsOperating system 20 threads
Operating system 20 threads
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

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