
OperatingSystemsCh6Process Scheduling1
Operating Systems Ch6 Process Scheduling 1

OutlineUserSpaceProcessProcessProcessKernelSpaceSchedulingAlgProcessSchedulellifecycle11ProcessCommunication&ProcessSchedulingSynchronizationntelContext-Core"i7switching
Outline 2 Process Communication & Synchronization Process Scheduling Scheduler Contextswitching Process Process Process Kernel Space User Space P P P Scheduling Alg Process lifecycle

Whyschedulingis needed· Process execution-Consistsof acycleof CPUexecutionand I/OwaitCPU burst +I/o burst160140120CPUburstdurationKouenbauy100806040200164082432burstduration (milliseconds)3
Why scheduling is needed • Process execution – Consists of a cycle of CPU execution and I/O wait – CPU burst + I/O burst 3 CPU burst duration

Why scheduling is neededQuestion.Howto improveCPUMultiprogrammingutilization(CPUismuchfasterthanI/O)?MultitaskingQuestion.Howtoimprovesystemresponsiveness (interactiveapplications)?A system may contain many processes which are at differentstates (ready for running, waiting for I/O)Scheduling is required because the number of computingresource-the CPU-islimited4
Why scheduling is needed 4 A system may contain many processes which are at different states (ready for running, waiting for I/O) Multiprogramming Question. How to improve CPU utilization (CPU is much faster than I/O)? Question. How to improve system responsiveness (interactive applications)? Multitasking Scheduling is required because the number of computing resource – the CPU – is limited

Topics- Process lifecycle- Process scheduling- Context switching- Scheduling criteria- Scheduling algorithms: Applications/Scenarios(intel)Core"i75
5 Topics - Process lifecycle - Process scheduling - Context switching - Scheduling criteria - Scheduling algorithms - Applications/Scenarios

Topics- Process lifecycleProcess schedulingContext switchingScheduling criteriaScheduling algorithmsApplications/Scenarios(intel)Core"i76
6 Topics - Process lifecycle - Process scheduling - Context switching - Scheduling criteria - Scheduling algorithms - Applications/Scenarios

Programmer'spointofview.. This is how a fresh programmer looks at a processlife cycle.int main(void)(3)intx=1;Runninggetchar();Terminationreturnx;(1)(2)Waitingfor resultsProcessStates
Programmer’s point of view. • This is how a fresh programmer looks at a process’ life cycle. 7 Running Waiting for results Termination Process States int main(void) { int x = 1; getchar(); return x; } (1) (2) (3)

Kernel's point of view..Big PictureNewTerminated(Justfork()-ed)(Zombie)ReadyRunningWaiting(blocked)ProcessStates8
Kernel’s point of view. 8 New (Just fork()-ed) Waiting (blocked) Terminated (Zombie) Process States Ready Running Big Picture

Kernel's point of view..The birth of aprocess.Exceptthefirstprocess"init"every process is created usingNewTerminatedfork().ReadyRunningWaiting(blocked)ProcessStates9
Kernel’s point of view. 9 Process States Ready Running The birth of a process. Except the first process “init”, every process is created using fork(). New Waiting (blocked) Terminated

Kernel's point of view..TheprocessisreadyIt means it is ready to run but is notrunningNewA process may become"ready" after...- it is just created by fork();- it has been running on the CPUforsometimeandtheOS choosesReadyanotherprocessto run;-returningfromblockedstates.All ready processes are kept on a listWait.called ready queuePCBTPCBzqueueheaderProcessheadreadyqueuetailStatesregistersregisters10
Kernel’s point of view. 10 Process States Ready Running New Waiting (blocked) Terminated The process is ready. It means it is ready to run but is not running. A process may become “ready” after. - it is just created by fork(); - it has been running on the CPU for some time and the OS chooses another process to run; - returning from blocked states. All ready processes are kept on a list called ready queue