SlideShare a Scribd company logo
1 of 19
Thread Scheduling
in Operating
Systems
What is thread
In an operating system
(OS), a thread refers to the
smallest unit of execution
within a process.
Thread Scheduling
Thread scheduling can be defined as the process of
determining the order and timing of execution for
individual threads within a system. Each thread
represents a sequence of instructions that needs to be
executed, and the scheduler is responsible for making
decisions about which thread should run next and for
how long.
Definition:
Thread scheduling is distinguishing between user-level and kernel-
level threads.
User-Level Threads:
• User-level threads are managed by a thread library, and the kernel
is unaware of them.
• The thread creation, scheduling, and management are handled by
the application or a user-level library, without involving the
operating system.
• Thread library schedules which thread of the process to run on
which LWP and how long.
Kernel-Level Threads:
• Kernel-level threads are managed by the operating system kernel,
and the kernel is responsible for their creation.
• Lightweight processes act as intermediaries between user-level
threads and kernel-level threads.
Example: When you open a new tab to visit a website, the browser
creates a user-level thread (representing the tab) and associates it
with a lightweight process. The lightweight process communicates
with the operating system kernel through kernel-level threads to
perform tasks like fetching data over the network, managing local
storage, and rendering graphics on the screen.
Contention Scope:
• The word Contention here refers to the competition
or fight among the user level threads access kernel
resources.
• It is defined by the application developer using the
thread library.
Types:
1. Process contention scope: The contention takes
place among thread within same process.(Priority
is specifies by the application developer during the
thread creation.)
2. System contention scope: The contention takes
place among all threads in the system.
Understanding the priority
levels and scheduling algorithms
is essential for effective thread
management. Proper task
allocation and CPU utilization
are key factors in achieving
optimal performance.
Thread scheduling can
be either preemptive
or non-preemptive
Preemptive Scheduling:
• In preemptive scheduling, the operating
system has the ability to interrupt a currently
running thread and allocate the CPU to
another thread.
• When a higher-priority process or thread is
identified, the scheduler initiates a context
switch.
Non-Preemptive Scheduling:
• In non-preemptive (or cooperative) scheduling, a
running thread continues execution until it
completes its task.
• The operating system does not forcibly interrupt
the running thread.
• Non-preemptive scheduling can be simpler to
implement but may lead to less responsive
systems, especially if a high-priority thread is
waiting for a lower-priority thread to finish.
Scheduling Algorithms
Various scheduling algorithms such as
Round Robin, Shortest Job First, and
Multi-Level Feedback Queue offer
different approaches to task
dispatching. Each algorithm has its own
impact on system performance and
fairness.
Round Robin :
• This algorithm follows a simple, cyclic approach,
allocating a fixed time slice to each task in a
circular manner.
• It ensures fairness by providing equal opportunities
to all tasks, preventing any single task from
monopolizing the CPU.
Shortest Job First :
• SJF prioritizes tasks based on their burst time,
executing the shortest job first.
• However, predicting the exact burst time in
practical systems can be challenging, making it
sensitive to inaccurate estimations.
Multi-Level Feedback Queue :
• MLFQ operates with multiple priority levels, typically High,
Medium, and Low. Each priority level represents a different
queue, and tasks move between these queues based on their
behavior.
• A task from the highest priority queue is given the CPU to
execute. If the task completes its execution within the time
quantum, it may stay in the same priority level or be promoted
to a higher one. If it uses up its time quantum, it might be
moved to a lower priority level.
Real-Time
Scheduling
Rate
Monotonic and Earliest
Deadline First are
popular real-time
scheduling
algorithms that ensure
timely task execution.
Thread Synchronization
Proper synchronization mechanisms
such as mutexes and semaphores
are essential for avoiding race
conditions and ensuring data
integrity. Synchronization
mechanisms should be designed to
avoid deadlock situations.
Conclusion
Optimizing thread scheduling is
essential for achieving system
efficiency and responsiveness. By
understanding scheduling algorithms
and adapting to evolving workloads,
we can ensure optimal resource
utilization and performance.
Thanks!
Presented By: Arahantha varma
Rollno: 220983
Class: 2 BCA

More Related Content

Similar to Thread scheduling...................pptx

How Operating system works.
How Operating system works. How Operating system works.
How Operating system works. Fahad Farooq
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .nathansel1
 
Os examples scheduling
Os examples schedulingOs examples scheduling
Os examples schedulingDana dia
 
thread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptthread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptnaghamallella
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentationTalha Shaikh
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...ssuser4a97d3
 
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
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptxYojanaFegade
 
Types of operating system.................
Types of operating system.................Types of operating system.................
Types of operating system.................harendersin82880
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating SystemDr. Pankaj Zope
 
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptx
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptxUNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptx
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptxLeahRachael
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...morganjohn3
 
Chip Multithreading Systems Need a New Operating System Scheduler
Chip Multithreading Systems Need a New Operating System Scheduler Chip Multithreading Systems Need a New Operating System Scheduler
Chip Multithreading Systems Need a New Operating System Scheduler Sarwan ali
 

Similar to Thread scheduling...................pptx (20)

How Operating system works.
How Operating system works. How Operating system works.
How Operating system works.
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
 
Os examples scheduling
Os examples schedulingOs examples scheduling
Os examples scheduling
 
thread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptthread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.ppt
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentation
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
 
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
 
Resource management
Resource managementResource management
Resource management
 
Thread
ThreadThread
Thread
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptx
 
Types of operating system.................
Types of operating system.................Types of operating system.................
Types of operating system.................
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating System
 
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptx
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptxUNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptx
UNIT 1 - UNDERSTANDINGTHE PRINCIPLES OF OPERATING SYSTEM.pptx
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
Introduction to operating systems
 Introduction to operating systems Introduction to operating systems
Introduction to operating systems
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
 
Chip Multithreading Systems Need a New Operating System Scheduler
Chip Multithreading Systems Need a New Operating System Scheduler Chip Multithreading Systems Need a New Operating System Scheduler
Chip Multithreading Systems Need a New Operating System Scheduler
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Thread scheduling...................pptx

  • 2. What is thread In an operating system (OS), a thread refers to the smallest unit of execution within a process.
  • 3. Thread Scheduling Thread scheduling can be defined as the process of determining the order and timing of execution for individual threads within a system. Each thread represents a sequence of instructions that needs to be executed, and the scheduler is responsible for making decisions about which thread should run next and for how long. Definition:
  • 4. Thread scheduling is distinguishing between user-level and kernel- level threads. User-Level Threads: • User-level threads are managed by a thread library, and the kernel is unaware of them. • The thread creation, scheduling, and management are handled by the application or a user-level library, without involving the operating system. • Thread library schedules which thread of the process to run on which LWP and how long.
  • 5. Kernel-Level Threads: • Kernel-level threads are managed by the operating system kernel, and the kernel is responsible for their creation. • Lightweight processes act as intermediaries between user-level threads and kernel-level threads. Example: When you open a new tab to visit a website, the browser creates a user-level thread (representing the tab) and associates it with a lightweight process. The lightweight process communicates with the operating system kernel through kernel-level threads to perform tasks like fetching data over the network, managing local storage, and rendering graphics on the screen.
  • 6. Contention Scope: • The word Contention here refers to the competition or fight among the user level threads access kernel resources. • It is defined by the application developer using the thread library.
  • 7. Types: 1. Process contention scope: The contention takes place among thread within same process.(Priority is specifies by the application developer during the thread creation.) 2. System contention scope: The contention takes place among all threads in the system.
  • 8. Understanding the priority levels and scheduling algorithms is essential for effective thread management. Proper task allocation and CPU utilization are key factors in achieving optimal performance.
  • 9. Thread scheduling can be either preemptive or non-preemptive
  • 10. Preemptive Scheduling: • In preemptive scheduling, the operating system has the ability to interrupt a currently running thread and allocate the CPU to another thread. • When a higher-priority process or thread is identified, the scheduler initiates a context switch.
  • 11. Non-Preemptive Scheduling: • In non-preemptive (or cooperative) scheduling, a running thread continues execution until it completes its task. • The operating system does not forcibly interrupt the running thread. • Non-preemptive scheduling can be simpler to implement but may lead to less responsive systems, especially if a high-priority thread is waiting for a lower-priority thread to finish.
  • 12. Scheduling Algorithms Various scheduling algorithms such as Round Robin, Shortest Job First, and Multi-Level Feedback Queue offer different approaches to task dispatching. Each algorithm has its own impact on system performance and fairness.
  • 13. Round Robin : • This algorithm follows a simple, cyclic approach, allocating a fixed time slice to each task in a circular manner. • It ensures fairness by providing equal opportunities to all tasks, preventing any single task from monopolizing the CPU.
  • 14. Shortest Job First : • SJF prioritizes tasks based on their burst time, executing the shortest job first. • However, predicting the exact burst time in practical systems can be challenging, making it sensitive to inaccurate estimations.
  • 15. Multi-Level Feedback Queue : • MLFQ operates with multiple priority levels, typically High, Medium, and Low. Each priority level represents a different queue, and tasks move between these queues based on their behavior. • A task from the highest priority queue is given the CPU to execute. If the task completes its execution within the time quantum, it may stay in the same priority level or be promoted to a higher one. If it uses up its time quantum, it might be moved to a lower priority level.
  • 16. Real-Time Scheduling Rate Monotonic and Earliest Deadline First are popular real-time scheduling algorithms that ensure timely task execution.
  • 17. Thread Synchronization Proper synchronization mechanisms such as mutexes and semaphores are essential for avoiding race conditions and ensuring data integrity. Synchronization mechanisms should be designed to avoid deadlock situations.
  • 18. Conclusion Optimizing thread scheduling is essential for achieving system efficiency and responsiveness. By understanding scheduling algorithms and adapting to evolving workloads, we can ensure optimal resource utilization and performance.
  • 19. Thanks! Presented By: Arahantha varma Rollno: 220983 Class: 2 BCA