SlideShare a Scribd company logo
Operating System
(Processes)
Lecture -2
By:
Aman Gupta
Assistant Professor
Operating systems - 2 1
Outline
 Process Concept
 Process Scheduling
 Operations on Processes
2Operating systems - 2
Process Concept
 An operating system executes a variety of
programs
 batch systems - jobs
 time-shared systems - user programs or tasks
 job and program used interchangeably
 Process - a program in execution
 process execution proceeds in a sequential fashion
 A process contains
 program counter, stack and data section
3Operating systems - 2
Process State
 A process changes state as it executes.
new
new admitted
interrupt
I/O or
event
completion
Scheduler
dispatch I/O or
event wait
exit
ready
running
terminated
waiting
4Operating systems - 2
Process States
 New - The process is being created.
 Running - Instructions are being executed.
 Waiting - Waiting for some event to occur.
 Ready - Waiting to be assigned to a
processor.
 Terminated - Process has finished execution.
5Operating systems - 2
Process Control Block
6Operating systems - 2
Process Control Block
 Contains information associated with each
process
 Process State - e.g. new, ready, running etc.
 Program Counter - address of next instruction to be
executed
 CPU registers - general purpose registers, stack pointer
etc.
 CPU scheduling information - process priority, pointer
 Memory Management information - base/limit information
 Accounting information - time limits, process number
 I/O Status information - list of I/O devices allocated
7Operating systems - 2
Process Scheduling Queues
 Job Queue - set of all processes in the system
 Ready Queue - set of all processes residing in main
memory, ready and waiting to execute.
 Device Queues - set of processes waiting for an I/O
device.
 Process migration between the various queues.
 Queue Structures - typically linked list, circular list
etc.
8Operating systems - 2
Process Queues
Device
Queue
Ready
Queue
9Operating systems - 2
Process Scheduling Queues
10Operating systems - 2
Schedulers
 Long-term scheduler (or job scheduler) -
 selects which processes should be brought into the ready
queue.
 invoked very infrequently (seconds, minutes); may be slow.
 controls the degree of multiprogramming
 Short term scheduler (or CPU scheduler) -
 selects which process should execute next and allocates
CPU.
 invoked very frequently (milliseconds) - must be very fast
 Medium Term Scheduler
 swaps out process temporarily
 balances load for better throughput
11Operating systems - 2
Scheduling Objectives
 Enforcement of fairness
 in allocating resources to processes
 Enforcement of priorities
 Make best use of available system resources
 Give preference to processes holding key
resources.
 Give preference to processes exhibiting good
behavior.
 Degrade gracefully under heavy loads.
Program Behavior Issues
 I/O boundedness
 short burst of CPU before blocking for I/O
 CPU boundedness
 extensive use of CPU before blocking for I/O
 Urgency and Priorities
 Frequency of preemption
 Process execution time
 Time sharing
 amount of execution time process has already received.
Basic Concepts
 Maximum CPU utilization obtained with
multiprogramming.
 CPU-I/O Burst Cycle
 Process execution consists of a cycle of CPU execution
and I/O wait.
CPU Scheduler
 Selects from among the processes in
memory that are ready to execute, and
allocates the CPU to one of them.
 Non-preemptive Scheduling
 Once CPU has been allocated to a process, the process
keeps the CPU until
 Process exits OR
 Process switches to waiting state
 Preemptive Scheduling
 Process can be interrupted and must release the CPU.
 Need to coordinate access to shared data
CPU Scheduling Decisions
 CPU scheduling decisions may take place
when a process:
 switches from running state to waiting state
 switches from running state to ready state
 switches from waiting to ready
 terminates
 Scheduling under 1 and 4 is non-preemptive.
 All other scheduling is preemptive.
CPU scheduling decisions
new
new admitted
interrupt
I/O or
event
completion
Scheduler
dispatch I/O or
event wait
exit
ready
running
terminated
waiting
Scheduling Criteria
 CPU Utilization
 Keep the CPU and other resources as busy as possible
 Throughput
 # of processes that complete their execution per time
unit.
 Turnaround time
 amount of time to execute a particular process from its
entry time.
Scheduling Criteria (cont.)
 Waiting time
 amount of time a process has been waiting in the ready
queue.
 Response Time (in a time-sharing
environment)
 amount of time it takes from when a request was
submitted until the first response is produced, NOT
output.
Optimization Criteria
 Max CPU Utilization
 Max Throughput
 Min Turnaround time
 Min Waiting time
 Min response time
First Come First Serve (FCFS)
Scheduling
 Policy: Process that requests the CPU FIRST
is allocated the CPU FIRST.
 FCFS is a non-preemptive algorithm.
 Implementation - using FIFO queues
 incoming process is added to the tail of the queue.
 Process selected for execution is taken from head of
queue.
 Performance metric - Average waiting time in
queue.
 Gantt Charts are used to visualize schedules.
First-Come, First-Served(FCFS)
Scheduling
 Example
Process Burst Time
P1 24
P2 3
P3 3
 Suppose the arrival
order for the processes
is
 P1, P2, P3
 Waiting time
 P1 = 0;
 P2 = 24;
 P3 = 27;
 Average waiting time
 (0+24+27)/3 = 17
0 24 27 30
P1 P2 P3
Gantt Chart for Schedule
FCFS Scheduling (cont.)
 Example
Process Burst Time
P1 24
P2 3
P3 3
 Suppose the arrival order
for the processes is
 P2, P3, P1
 Waiting time
 P1 = 6; P2 = 0; P3 = 3;
 Average waiting time
 (6+0+3)/3 = 3 , better..
 Convoy Effect:
 short process behind long
process, e.g. 1 CPU bound
process, many I/O bound
processes.
0 3 6 30
P1P2 P3
Gantt Chart for Schedule
Shortest-Job-First(SJF) Scheduling
 Associate with each process the length of its next
CPU burst. Use these lengths to schedule the
process with the shortest time.
 Two Schemes:
 Scheme 1: Non-preemptive
 Once CPU is given to the process it cannot be preempted
until it completes its CPU burst.
 Scheme 2: Preemptive
 If a new CPU process arrives with CPU burst length less
than remaining time of current executing process, preempt.
Also called Shortest-Remaining-Time-First (SRTF).
 SJF is optimal - gives minimum average waiting time for
a given set of processes.
Non-Preemptive SJF Scheduling
 Example
Process Arrival TimeBurst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0 8 16
P1 P2P3
Gantt Chart for Schedule
P4
127
Average waiting time =
(0+6+3+7)/4 = 4
Preemptive SJF Scheduling(SRTF)
 Example
Process Arrival TimeBurst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0 7 16
P1 P2P3
Gantt Chart for Schedule
P4
115
Average waiting time =
(9+1+0+2)/4 = 3
P2 P1
2 4
Priority Scheduling
 A priority value (integer) is associated with
each process. Can be based on
 Cost to user
 Importance to user
 Aging
 %CPU time used in last X hours.
 CPU is allocated to process with the highest
priority.
 Preemptive
 Nonpreemptive
Priority Scheduling (cont.)
 SJN is a priority scheme where the priority is
the predicted next CPU burst time.
 Problem
 Starvation!! - Low priority processes may never execute.
 Solution
 Aging - as time progresses increase the priority of the
process.
Round Robin (RR)
 Each process gets a small unit of CPU time
 Time quantum usually 10-100 milliseconds.
 After this time has elapsed, the process is preempted and
added to the end of the ready queue.
 n processes, time quantum = q
 Each process gets 1/n CPU time in chunks of at most q
time units at a time.
 No process waits more than (n-1)q time units.
 Performance
 Time slice q too large - FIFO behavior
 Time slice q too small - Overhead of context switch is
too expensive.
 Heuristic - 70-80% of jobs block within timeslice
Round Robin Example
 Time Quantum = 20
Process Burst Time
P1 53
P2 17
P3 68
P4 24
0
P1 P4P3
Gantt Chart for Schedule
P1P2
20
P3 P3 P3P4 P1
37 57 77 97 117 121 134 154 162
Typically, higher average turnaround time than SRTF, but better response
Ad

More Related Content

What's hot (20)

Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
Christalin Nelson
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
Sweetestangel Kochar
 
T iming diagrams of 8085
T iming diagrams of 8085T iming diagrams of 8085
T iming diagrams of 8085
Salim Khan
 
parallel language and compiler
parallel language and compilerparallel language and compiler
parallel language and compiler
Vignesh Tamil
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
Damian T. Gordon
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
ShubhamGupta345141
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
Suraj Kumar
 
Address Binding Scheme
Address Binding SchemeAddress Binding Scheme
Address Binding Scheme
Rajesh Piryani
 
Deadlock
DeadlockDeadlock
Deadlock
Mohd Arif
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
Shanu Kumar
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
Ravi Kumar Patel
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor scheduling
Shashank Kapoor
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
Mohammad Hafiz-Al-Masud
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
usmankiyani1
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
Ali Haider
 
Scheduling
SchedulingScheduling
Scheduling
pradeepa velmurugan
 
Congestion control
Congestion controlCongestion control
Congestion control
Principal,Guru Nanak Institute of Technology, Nagpur
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systems
jamunaashok
 

Similar to Operating System Scheduling (20)

Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Ch6
Ch6Ch6
Ch6
C.U
 
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILEDCPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
VADAPALLYPRAVEENKUMA1
 
Ch5
Ch5Ch5
Ch5
Lokesh Kannaiyan
 
Process Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems ratingProcess Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems rating
Aryan904173
 
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
OSCh6
OSCh6OSCh6
OSCh6
Joe Christensen
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
Supriya Shrivastava
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Unit2 CPU Scheduling 24252 (sssssss1).ppt
Unit2 CPU Scheduling 24252 (sssssss1).pptUnit2 CPU Scheduling 24252 (sssssss1).ppt
Unit2 CPU Scheduling 24252 (sssssss1).ppt
AkashPundir2
 
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBtUnit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
AkashPundir2
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
jamilaltiti1
 
Distributed Operating System_2
Distributed Operating System_2Distributed Operating System_2
Distributed Operating System_2
Dr Sandeep Kumar Poonia
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
Harshit Jain
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
 
ERTS UNIT 5.pptx
ERTS UNIT 5.pptxERTS UNIT 5.pptx
ERTS UNIT 5.pptx
Pavithra525349
 
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALESDISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
2021207019est
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
Sonali Chauhan
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
Dr. Mazin Mohamed alkathiri
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Ch6
Ch6Ch6
Ch6
C.U
 
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILEDCPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
VADAPALLYPRAVEENKUMA1
 
Process Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems ratingProcess Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems rating
Aryan904173
 
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Unit2 CPU Scheduling 24252 (sssssss1).ppt
Unit2 CPU Scheduling 24252 (sssssss1).pptUnit2 CPU Scheduling 24252 (sssssss1).ppt
Unit2 CPU Scheduling 24252 (sssssss1).ppt
AkashPundir2
 
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBtUnit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
AkashPundir2
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
jamilaltiti1
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
Harshit Jain
 
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALESDISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
2021207019est
 
Ad

Recently uploaded (20)

How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Ad

Operating System Scheduling

  • 1. Operating System (Processes) Lecture -2 By: Aman Gupta Assistant Professor Operating systems - 2 1
  • 2. Outline  Process Concept  Process Scheduling  Operations on Processes 2Operating systems - 2
  • 3. Process Concept  An operating system executes a variety of programs  batch systems - jobs  time-shared systems - user programs or tasks  job and program used interchangeably  Process - a program in execution  process execution proceeds in a sequential fashion  A process contains  program counter, stack and data section 3Operating systems - 2
  • 4. Process State  A process changes state as it executes. new new admitted interrupt I/O or event completion Scheduler dispatch I/O or event wait exit ready running terminated waiting 4Operating systems - 2
  • 5. Process States  New - The process is being created.  Running - Instructions are being executed.  Waiting - Waiting for some event to occur.  Ready - Waiting to be assigned to a processor.  Terminated - Process has finished execution. 5Operating systems - 2
  • 7. Process Control Block  Contains information associated with each process  Process State - e.g. new, ready, running etc.  Program Counter - address of next instruction to be executed  CPU registers - general purpose registers, stack pointer etc.  CPU scheduling information - process priority, pointer  Memory Management information - base/limit information  Accounting information - time limits, process number  I/O Status information - list of I/O devices allocated 7Operating systems - 2
  • 8. Process Scheduling Queues  Job Queue - set of all processes in the system  Ready Queue - set of all processes residing in main memory, ready and waiting to execute.  Device Queues - set of processes waiting for an I/O device.  Process migration between the various queues.  Queue Structures - typically linked list, circular list etc. 8Operating systems - 2
  • 11. Schedulers  Long-term scheduler (or job scheduler) -  selects which processes should be brought into the ready queue.  invoked very infrequently (seconds, minutes); may be slow.  controls the degree of multiprogramming  Short term scheduler (or CPU scheduler) -  selects which process should execute next and allocates CPU.  invoked very frequently (milliseconds) - must be very fast  Medium Term Scheduler  swaps out process temporarily  balances load for better throughput 11Operating systems - 2
  • 12. Scheduling Objectives  Enforcement of fairness  in allocating resources to processes  Enforcement of priorities  Make best use of available system resources  Give preference to processes holding key resources.  Give preference to processes exhibiting good behavior.  Degrade gracefully under heavy loads.
  • 13. Program Behavior Issues  I/O boundedness  short burst of CPU before blocking for I/O  CPU boundedness  extensive use of CPU before blocking for I/O  Urgency and Priorities  Frequency of preemption  Process execution time  Time sharing  amount of execution time process has already received.
  • 14. Basic Concepts  Maximum CPU utilization obtained with multiprogramming.  CPU-I/O Burst Cycle  Process execution consists of a cycle of CPU execution and I/O wait.
  • 15. CPU Scheduler  Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.  Non-preemptive Scheduling  Once CPU has been allocated to a process, the process keeps the CPU until  Process exits OR  Process switches to waiting state  Preemptive Scheduling  Process can be interrupted and must release the CPU.  Need to coordinate access to shared data
  • 16. CPU Scheduling Decisions  CPU scheduling decisions may take place when a process:  switches from running state to waiting state  switches from running state to ready state  switches from waiting to ready  terminates  Scheduling under 1 and 4 is non-preemptive.  All other scheduling is preemptive.
  • 17. CPU scheduling decisions new new admitted interrupt I/O or event completion Scheduler dispatch I/O or event wait exit ready running terminated waiting
  • 18. Scheduling Criteria  CPU Utilization  Keep the CPU and other resources as busy as possible  Throughput  # of processes that complete their execution per time unit.  Turnaround time  amount of time to execute a particular process from its entry time.
  • 19. Scheduling Criteria (cont.)  Waiting time  amount of time a process has been waiting in the ready queue.  Response Time (in a time-sharing environment)  amount of time it takes from when a request was submitted until the first response is produced, NOT output.
  • 20. Optimization Criteria  Max CPU Utilization  Max Throughput  Min Turnaround time  Min Waiting time  Min response time
  • 21. First Come First Serve (FCFS) Scheduling  Policy: Process that requests the CPU FIRST is allocated the CPU FIRST.  FCFS is a non-preemptive algorithm.  Implementation - using FIFO queues  incoming process is added to the tail of the queue.  Process selected for execution is taken from head of queue.  Performance metric - Average waiting time in queue.  Gantt Charts are used to visualize schedules.
  • 22. First-Come, First-Served(FCFS) Scheduling  Example Process Burst Time P1 24 P2 3 P3 3  Suppose the arrival order for the processes is  P1, P2, P3  Waiting time  P1 = 0;  P2 = 24;  P3 = 27;  Average waiting time  (0+24+27)/3 = 17 0 24 27 30 P1 P2 P3 Gantt Chart for Schedule
  • 23. FCFS Scheduling (cont.)  Example Process Burst Time P1 24 P2 3 P3 3  Suppose the arrival order for the processes is  P2, P3, P1  Waiting time  P1 = 6; P2 = 0; P3 = 3;  Average waiting time  (6+0+3)/3 = 3 , better..  Convoy Effect:  short process behind long process, e.g. 1 CPU bound process, many I/O bound processes. 0 3 6 30 P1P2 P3 Gantt Chart for Schedule
  • 24. Shortest-Job-First(SJF) Scheduling  Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.  Two Schemes:  Scheme 1: Non-preemptive  Once CPU is given to the process it cannot be preempted until it completes its CPU burst.  Scheme 2: Preemptive  If a new CPU process arrives with CPU burst length less than remaining time of current executing process, preempt. Also called Shortest-Remaining-Time-First (SRTF).  SJF is optimal - gives minimum average waiting time for a given set of processes.
  • 25. Non-Preemptive SJF Scheduling  Example Process Arrival TimeBurst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4 0 8 16 P1 P2P3 Gantt Chart for Schedule P4 127 Average waiting time = (0+6+3+7)/4 = 4
  • 26. Preemptive SJF Scheduling(SRTF)  Example Process Arrival TimeBurst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4 0 7 16 P1 P2P3 Gantt Chart for Schedule P4 115 Average waiting time = (9+1+0+2)/4 = 3 P2 P1 2 4
  • 27. Priority Scheduling  A priority value (integer) is associated with each process. Can be based on  Cost to user  Importance to user  Aging  %CPU time used in last X hours.  CPU is allocated to process with the highest priority.  Preemptive  Nonpreemptive
  • 28. Priority Scheduling (cont.)  SJN is a priority scheme where the priority is the predicted next CPU burst time.  Problem  Starvation!! - Low priority processes may never execute.  Solution  Aging - as time progresses increase the priority of the process.
  • 29. Round Robin (RR)  Each process gets a small unit of CPU time  Time quantum usually 10-100 milliseconds.  After this time has elapsed, the process is preempted and added to the end of the ready queue.  n processes, time quantum = q  Each process gets 1/n CPU time in chunks of at most q time units at a time.  No process waits more than (n-1)q time units.  Performance  Time slice q too large - FIFO behavior  Time slice q too small - Overhead of context switch is too expensive.  Heuristic - 70-80% of jobs block within timeslice
  • 30. Round Robin Example  Time Quantum = 20 Process Burst Time P1 53 P2 17 P3 68 P4 24 0 P1 P4P3 Gantt Chart for Schedule P1P2 20 P3 P3 P3P4 P1 37 57 77 97 117 121 134 154 162 Typically, higher average turnaround time than SRTF, but better response