Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
CPU SCHEDULING
T.Y.B.Sc. (CS)
By: Ms. Farhat Rahat Ali Shaikh
CONTENTS
 Introduction
 CPU Scheduling: Dispatcher
 Types of CPU Scheduling
 Non – Preemptive Scheduling
 Preemptive Scheduling
 CPU Scheduling: Scheduling Criteria
 Scheduling Algorithms
 First Come First Serve(FCFS) Scheduling
 Shortest-Job-First(SJF) Scheduling
 Shortest Remaining Time First (SRTF) Scheduling
 Priority Non - Preemptive Scheduling
 Priority Preemptive Scheduling
 Round Robin(RR) Scheduling
2
Introduction
 CPU scheduling is a process which allows one process to use the CPU while the execution
of another process is on hold(in waiting state) due to unavailability of any resource like
I/O etc., thereby making full use of CPU. The aim of CPU scheduling is to make the
system efficient, fast and fair.
 Whenever the CPU becomes idle, the operating system must select one of the processes in
the ready queue to be executed. The selection process is carried out by the short-term
scheduler (or CPU scheduler). The scheduler selects from among the processes in
memory that are ready to execute, and allocates the CPU to one of them.
3
CPU Scheduling: Dispatcher
 The dispatcher is the module that gives control of the CPU to the process selected by the
short-term scheduler. This function involves:
 Switching context
 Switching to user mode
 Jumping to the proper location in the user program to restart that program from
where it left last time.
 The dispatcher should be as fast as possible, given that it is invoked during every process
switch. The time taken by the dispatcher to stop one process and start another process is
known as the Dispatch Latency.
4

Recommended for you

Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)

It consists of CPU scheduling algorithms, examples, scheduling problems, realtime scheduling algorithms and issues. Multiprocessing and multicore scheduling.

schedulingfcfssjf
Multilevel queue scheduling
Multilevel queue schedulingMultilevel queue scheduling
Multilevel queue scheduling

Multilevel queue scheduling divides processes into separate queues based on attributes like priority or process type. The ready queue is divided into a system process queue, interactive process queue, and background process queue, which are run in order of decreasing priority. Each queue can use a different scheduling algorithm like first come first serve, shortest job first, or round robin. This scheduling method allows for different treatment of process types but risks starvation of lower priority queues if higher priority processes continue arriving.

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies

The document discusses different memory management strategies: - Swapping allows processes to be swapped temporarily out of memory to disk, then back into memory for continued execution. This improves memory utilization but incurs long swap times. - Contiguous memory allocation allocates processes into contiguous regions of physical memory using techniques like memory mapping and dynamic storage allocation with first-fit or best-fit. This can cause external and internal fragmentation over time. - Paging permits the physical memory used by a process to be noncontiguous by dividing memory into pages and mapping virtual addresses to physical frames, allowing more efficient use of memory but requiring page tables for translation.

operating systems
Types of CPU Scheduling
 CPU scheduling decisions may take place under the following four circumstances:
 When a process switches from the running state to the waiting state (for I/O request or
invocation of wait for the termination of one of the child processes).
 When a process switches from the running state to the ready state (for example, when
an interrupt occurs).
 When a process switches from the waiting state to the ready state (for example,
completion of I/O).
 When a process terminates.
 In circumstances 1 and 4, there is no choice in terms of scheduling. A new process(if one
exists in the ready queue) must be selected for execution. There is a choice, however in
circumstances 2 and 3.
 When Scheduling takes place only under circumstances 1 and 4, we say the scheduling
scheme is Non-preemptive; otherwise the scheduling scheme is Preemptive.
5
Types of CPU Scheduling
 Non-Preemptive Scheduling:
 In this type of scheduling, once the CPU has been allocated to a process, the process
keeps the CPU until it releases the CPU either by terminating or by switching to the
waiting state.
 It is the only method that can be used on certain hardware platforms, because It does
not require the special hardware(for example: a timer) needed for preemptive
scheduling.
 Preemptive Scheduling:
 In this type of Scheduling, the tasks are usually assigned with priorities. At times it is
necessary to run a certain task that has a higher priority before another task although
it is running.
 Therefore, the running task is interrupted for some time and resumed later when the
priority task has finished its execution.
6
CPU Scheduling: Scheduling Criteria
 There are many different criteria's to check when considering the "best" scheduling
algorithm, they are:
 CPU Utilization: To make out the best use of CPU and not to waste any CPU cycle, CPU
would be working most of the time(Ideally 100% of the time). Considering a real
system, CPU usage should range from 40% (lightly loaded) to 90% (heavily loaded.)
 Throughput: It is the total number of processes completed per unit time or rather say
total amount of work done in a unit of time. This may range from 10/second to
1/hour depending on the specific processes.
 Turnaround Time: It is the amount of time taken to execute a particular process, i.e.
The interval from time of submission of the process to the time of completion of the
process(Wall clock time).
 Waiting Time: It is the total time spent by the process in the ready state waiting to get
control on the CPU.
7
CPU Scheduling: Scheduling Criteria
 Load Average: It is the average number of processes residing in the ready queue
waiting for their turn to get into the CPU.
 Response Time: Amount of time it takes from when a request was submitted until the
first response is produced. Remember, it is the time till the first response and not the
completion of process execution(final response).
 In general CPU utilization and Throughput are maximized and other factors are
reduced for proper optimization.
8

Recommended for you

Semaphore
SemaphoreSemaphore
Semaphore

This document discusses semaphores, which are integer variables that coordinate access to shared resources. It describes counting semaphores, which allow multiple processes to access a critical section simultaneously up to a set limit, and binary semaphores, which only permit one process at a time. Key differences are that counting semaphores can have any integer value while binary semaphores are limited to 0 or 1, and counting semaphores allow multiple slots while binary semaphores provide strict mutual exclusion. Limitations of semaphores include potential priority inversion issues and deadlocks if not used properly.

semaphorecountingcounting semaphore
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors

The document summarizes key concepts in process synchronization and concurrency control, including: 1) Process synchronization techniques like semaphores, monitors, and atomic transactions that ensure orderly access to shared resources. Semaphores use wait() and signal() operations while monitors provide mutual exclusion through condition variables. 2) Concurrency control algorithms like locking and two-phase locking that ensure serializability of concurrent transactions accessing a database. Locking associates locks with data items to control concurrent access. 3) Challenges in concurrency control like deadlocks, priority inversion, and starvation that synchronization mechanisms aim to prevent. Log-based recovery with write-ahead logging and checkpoints is used to ensure atomicity of transactions in

Operating System Scheduling Algorithms
Operating System Scheduling AlgorithmsOperating System Scheduling Algorithms
Operating System Scheduling Algorithms

To decide which process to execute first and which process to execute last to achieve maximum CPU utilisation, there are some defined algorithms.

operating systemalgorithmstechnology
Scheduling Algorithms
 To decide which process to execute first and which process to execute last to achieve
maximum CPU utilization, we have various scheduling algorithms as follows :
 First Come First Serve(FCFS) Scheduling
 Shortest Job First(SJF) Scheduling
 Priority Scheduling
 Round Robin(RR) Scheduling
9
First Come First Serve(FCFS)
Scheduling
 In the "First come first serve" scheduling algorithm, the process which arrives first, gets
executed first, or we can say that the process which requests the CPU first, gets the CPU
allocated first.
 It is a Non-preemptive Scheduling algorithm.
 Easy to understand and implement.
 Its implementation is based on FIFO queue.
 Poor in performance as average wait time is high.
 This is used in Batch Systems.
10
First Come First Serve(FCFS)
Scheduling
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given jobs:
11
Jobs Arrival Time (A.T.) Burst Time (B.T.)
J1 1 5
J2 0 3
J3 2 2
J4 3 4
J5 2 8
First Come First Serve(FCFS)
Scheduling
 Solution: Gantt Chart
12
Jobs A.T. B.T. T.A.T.
(F.T. – A.T.)
W.T.
(S.T. – A.T.)
J1 1 5
J2 0 3
J3 2 2
J4 3 4
J5 2 8
J2
0 3
J1
8
J3
10
J5
18
J4
22
S.T. F.T.
8 – 1 = 7
3 – 0 = 3
10 – 2 = 8
22 – 3 = 19
18 – 2 = 16
S.T.
F.T.
S.T.
F.T.
S.T.
F.T.
S.T.
F.T.
3 – 1 = 2
0 – 0 = 0
8 – 2 = 6
18 – 3 = 15
10 – 2 = 8
Avg. T.A.T. = 53
5
=10.6 ms
Avg. W.T. = 31
5
=6.2 ms
Total 53 ms. 31 ms.
S.T. = Start/Service Time
F.T. = Finish Time

Recommended for you

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling

Process Scheduling : Scheduling criteria, preemptive & non-preemptive scheduling, scheduling algorithms

operating systemaku patnaunit 3
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx

Inter-process communication (IPC) allows processes to communicate and synchronize. Common IPC methods include pipes, message queues, shared memory, semaphores, and mutexes. Pipes provide unidirectional communication while message queues allow full-duplex communication through message passing. Shared memory enables processes to access the same memory region. Direct IPC requires processes to explicitly name communication partners while indirect IPC uses shared mailboxes.

Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms

The document discusses various scheduling algorithms used in operating systems including: - First Come First Serve (FCFS) scheduling which services processes in the order of arrival but can lead to long waiting times. - Shortest Job First (SJF) scheduling which prioritizes the shortest processes first to minimize waiting times. It can be preemptive or non-preemptive. - Priority scheduling assigns priorities to processes and services the highest priority process first, which can potentially cause starvation of low priority processes. - Round Robin scheduling allows equal CPU access to all processes by allowing each a small time quantum or slice before preempting to the next process.

schedulingcpu schedulingoperating system
First Come First Serve(FCFS)
Scheduling
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
13
Process Arrival Time (A.T.) Burst Time (B.T.)
P1 1 5
P2 0 6
P3 1 2
P4 0 4
Avg. T.A.T. = 11.5 ms
Avg. W.T. = 7.2 ms
Shortest Job First(SJF) Scheduling
 Shortest Job First scheduling works on the process with the shortest burst time or duration
first.
 This is the best approach to minimize waiting time.
 Easy to implement in Batch systems where required CPU time is known in advance.
 Impossible to implement in interactive systems where required CPU time is not known.
 Processer should know in advance how much time process will take.
 It is of two types:
 Non Pre-emptive (SJF)
 Pre-emptive (SRTF)
14
Shortest Job First (SJF)
Non - Preemptive
 In this type of scheduling CPU allocated to the process(min burst time) cannot be
preempted until completes its CPU burst.
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given jobs:
15
Jobs Arrival Time (A.T.) Burst Time (B.T.)
J1 0 4
J2 1 1
J3 2 2
J4 3 1
Shortest Job First (SJF)
Non - Preemptive
 Solution: Gantt Chart
16
Jobs A.T. B.T. T.A.T.
(F.T. – A.T.)
W.T.
(S.T. – A.T.)
J1 0 4
J2 1 1
J3 2 2
J4 3 1
J1
0 4
J2
5
J4
6
J3
8
S.T. F.T.
4 – 0 = 4
5 – 1 = 4
8 – 2 = 6
6 – 3 = 3
S.T.F.T. S.T.
F.T.
S.T.
F.T.
0 – 0 = 0
4 – 1 = 3
6 – 2 = 4
5 – 3 = 2
Avg. T.A.T. = 17
4
=4.2 ms
Avg. W.T. = 9
4
=2.2 ms
Total 17 ms. 9 ms.
S.T. = Start/Service Time
F.T. = Finish Time

Recommended for you

Operating Systems
Operating SystemsOperating Systems
Operating Systems

The document provides an overview of operating systems, including what constitutes an OS (kernel, system programs, application programs), storage device hierarchy, system calls, process creation and states, process scheduling, inter-process communication methods like shared memory and pipes, synchronization techniques like mutexes and semaphores, readers-writers problem, and potential for deadlocks. Key concepts covered include kernel mode vs user mode, process control blocks, context switching, preemption, and requirements for deadlock situations.

linuxwindowsos
Context Switching
Context SwitchingContext Switching
Context Switching

The document discusses the actions taken by the kernel during a context switch between processes. It explains that a context switch involves suspending the currently running process, storing its context in the Process Control Block (PCB), and loading and resuming the context of another process from its PCB. The PCB contains information about the process state, registers, memory management, and more. Context switching has significant overhead as it involves saving and loading all this process context data.

Module 3-cpu-scheduling
Module 3-cpu-schedulingModule 3-cpu-scheduling
Module 3-cpu-scheduling

This document provides an overview of CPU scheduling concepts including multiprogramming, multitasking, process creation, the short-term scheduler, process control blocks, the long-term scheduler, and the medium-term scheduler. It also discusses classifications of processes as interactive, batch, or real-time processes and as I/O-bound or CPU-bound processes. Finally, it introduces common CPU scheduling algorithms like first-come first-served (FCFS), shortest job first (SJF), and round-robin (RR).

Shortest Job First (SJF)
Non - Preemptive
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
17
Jobs Arrival Time (A.T.) Burst Time (B.T.)
P1 3 5
P2 0 2
P3 4 2
P4 5 3
Shortest Job First (SJF)
Non - Preemptive
 Solution: Gantt Chart
18
Jobs A.T. B.T. T.A.T.
(F.T. – A.T.)
W.T.
(S.T. – A.T.)
P1 3 5
P2 0 2
P3 4 2
P4 5 3
P2
0 2
P1
14
P4
9
P3
6
S.T. F.T.
14 – 3 = 11
2 – 0 = 2
6 – 4 = 2
9 – 5 = 4
S.T.F.T. S.T.
F.T.S.T. F.T.
9 – 3 = 6
0 – 0 = 0
4 – 4 = 0
6 – 5 = 1
Avg. T.A.T. = 19
4
=4.75 ms
Avg. W.T. = 7
4
=1.75 ms
Total 19 ms. 7 ms.
S.T. = Start/Service Time
F.T. = Finish Time
4
Idle state
Shortest Job First (SJF)
Non - Preemptive
 Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
19
Process Arrival Time (A.T.) Burst Time (B.T.)
P1 1.5 5
P2 0 1
P3 2 2
P4 3 4
Avg. T.A.T. = 4.875 ms
Avg. W.T. = 1.875 ms
Shortest Remaining Time First
(SRTF) Preemptive
 In Preemptive Shortest Job First Scheduling, jobs are put into ready queue as they arrive,
but as a process with short burst time arrives, the existing process is preempted or removed
from execution, and the shorter job is executed first.
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given jobs:
20
Jobs Arrival Time (A.T.) Burst Time (B.T.)
J1 0 4
J2 1 1
J3 2 2
J4 3 1

Recommended for you

CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi

CS8461 - Operating System Laboratory Manual prepared for the Engineering graduates admitted under 2017 Regulations, Anna University affiliated institutions of TamilNadu,India

operating system laboratory manual
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm

The document discusses Windows XP's scheduling algorithm. It uses a priority-based, preemptive approach with 32 priority levels divided into variable and real-time classes. The scheduler ensures the highest priority thread runs by maintaining queues for each priority level and traversing from highest to lowest. Threads start at the process' base priority and may have their priority lowered after time quantums expire to limit CPU consumption of compute-intensive threads.

System calls
System callsSystem calls
System calls

This presentation discusses system calls and provides an overview of their key aspects: System calls provide an interface between processes and the operating system. They allow programs to request services from the OS like reading/writing files. There are different methods of passing parameters to the OS, such as via registers, parameter blocks, or pushing to the stack. System calls fall into categories including process control, file management, device management, information maintenance, and communication. An example is given of how system calls would be used in a program to copy data between two files.

Shortest Remaining Time First
(SRTF) Preemptive
 Solution: Gantt Chart
21
Jobs A.T. B.T. T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
J1 0 4
J2 1 1
J3 2 2
J4 3 1
J1
0 1
J2
2
J4
5
J3
4
8 – 0 = 8
2 – 1 = 1
4 – 2 = 2
5 – 3 = 2
F.T. F.T. F.T.
8 – 4 = 4
1 – 1 = 0
2 – 2 = 0
2 – 1 = 1
Avg. T.A.T. = 13
4
=3.25 ms
Avg. W.T. = 5
4
=1.25 ms
Total 13 ms. 5 ms.
F.T. = Finish Time
J3
3
J1
8
F.T.
CPU
J1 =
J2 =
J3 =
J4 =
3 =>
1 =>
2 =>
1 =>
0
1 => 0
0
0
Shortest Remaining Time First
(SRTF) Preemptive
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
22
Process Arrival Time (A.T.) Burst Time (B.T.)
P1 1.5 5
P2 0 1
P3 2 2
P4 3 4
Shortest Remaining Time First
(SRTF) Preemptive
 Solution: Gantt Chart
23
Jobs A.T. B.T. T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
P1 1.5 5
P2 0 1
P3 2 2
P4 3 4
P2
0 1 1.5
P3
4
P3
3
12.5 – 1.5 = 11
1 – 0 = 1
4 – 2 = 2
8 – 3 = 5
F.T. F.T. F.T.
11 – 5 = 6
1 – 1 = 0
2 – 2 = 0
5 – 4 = 1
Avg. T.A.T. = 19
4
=4.75 ms
Avg. W.T. = 7
4
=1.75 ms
Total 19 ms. 7 ms.
F.T. = Finish Time
P1
2
P4
8
F.T.
CPU
P2 =
P1 =
P3 =
P4 =
4.5 =>
0
2 =>
4 =>
0
1 => 0
0
Idle state
P1
12.5
Shortest Remaining Time First
(SRTF) Preemptive
 Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
24
Jobs Arrival Time (A.T.) Burst Time (B.T.)
P1 3 5
P2 0 2
P3 4 2
P4 5 3
Avg. T.A.T. = 4.5 ms
Avg. W.T. = 1.5 ms

Recommended for you

CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms

The document discusses different CPU scheduling algorithms used in operating systems. It describes non-preemptive and preemptive scheduling and explains the key differences. It then covers four common scheduling algorithms - first come first served (FCFS), round robin, priority scheduling, and shortest job first (SJF) - and compares their advantages and disadvantages.

computer science (bca)
Memory management
Memory managementMemory management
Memory management

The document discusses memory management techniques used in operating systems. It describes logical vs physical addresses and how relocation registers map logical addresses to physical addresses. It covers contiguous and non-contiguous storage allocation, including paging and segmentation. Paging divides memory into fixed-size frames and pages, using a page table and translation lookaside buffer (TLB) for address translation. Segmentation divides memory into variable-sized segments based on a program's logical structure. Virtual memory and demand paging are also covered, along with page replacement algorithms like FIFO, LRU and optimal replacement.

memory managementoperating systemoperating systems
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba

The document discusses different scheduling algorithms used by operating systems. It begins by explaining that the scheduler decides which process to activate from the ready queue when multiple processes are runnable. There are long-term, medium-term, and short-term schedulers that control admission of jobs, memory allocation, and CPU sharing respectively. The goal of scheduling is to optimize system performance and resource utilization while providing responsive service. Common algorithms include first-come first-served (FCFS), shortest job first (SJF), priority scheduling, and round-robin. FCFS schedules processes in the order of arrival while SJF selects the shortest job first. Priority scheduling preempts lower priority jobs.

Priority Scheduling
 Priority scheduling is one of the most common scheduling algorithms in batch systems.
 Each process is assigned a priority. Process with highest priority is to be executed first and
so on.
 Processes with same priority are executed on first come first serve basis.
 Priority can be decided based on memory requirements, time requirements or any other
resource requirement.
 It is of two types:
 Non – Preemptive Scheduling
 Preemptive Scheduling
25
Non –Preemptive Priority
Scheduling
 In case of non – preemptive priority scheduling algorithm if a new process arrives with a
higher priority than the current running process, the incoming process is put at the head
of the ready queue, which means after the execution of the current process it will be
processed.
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given jobs:
26
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
J1 0 10 3
J2 4 5 0 (High)
J3 3 2 1
J4 5 16 2
J5 2 8 4 (Low)
Non –Preemptive Priority
Scheduling
 Solution: Gantt Chart
27
Jobs A.T. B.T. Priority
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
J1 0 10 3
J2 4 5 0 (High)
J3 3 2 1
J4 5 16 2
J5 2 8 4 (Low)
J1
0 10
J2
15
J5
41
J4
33
10 – 0 = 10
15 – 4 = 11
17 – 3 = 14
33 – 5 = 28
F.T. F.T. F.T.
10 – 10 = 0
11 – 5 = 6
14 – 2 = 12
28 – 16 = 12
Avg. T.A.T. = 102
5
=20.4 ms
Avg. W.T. = 61
5
=12.2 ms
Total 102 ms. 61 ms.
F.T. = Finish Time
J3
17
F.T. F.T.
41 – 2 = 39 39 – 8 = 31
Non –Preemptive Priority
Scheduling
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
28
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
P1 1 5 1 (High)
P2 0 6 2
P3 1 2 1
P4 0 4 3 (Low)
P5 2 3 2

Recommended for you

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

CPU SCHEDULING

Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf

The document discusses operating system scheduling. It defines key scheduling criteria like CPU utilization, throughput, turnaround time, waiting time, and response time. It also outlines common scheduling algorithms like first-come first-served (FCFS), shortest-job-next (SJN), priority scheduling, shortest remaining time, and round robin. For each algorithm, it provides examples of how they work and how to calculate metrics like waiting time and turnaround time. It also distinguishes between time-sharing systems, which context switch between processes frequently for fast response, and parallel processing systems, which divide programs across multiple processors.

operating systemosscheduling
Process management in os
Process management in osProcess management in os
Process management in os

1. Process management is an integral part of operating systems for allocating resources, enabling information sharing, and protecting processes. The OS maintains data structures describing each process's state and resource ownership. 2. Processes go through discrete states and events can cause state changes. Scheduling selects processes to run from ready, device, and job queues using algorithms like round robin, shortest job first, and priority scheduling. 3. CPU scheduling aims to maximize utilization and throughput while minimizing waiting times using criteria like response time, turnaround time, and fairness between processes.

Non –Preemptive Priority
Scheduling
 Solution: Gantt Chart
29
Jobs A.T. B.T. Priority
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
P1 1 5 1 (High)
P2 0 6 2
P3 1 2 1
P4 0 4 3 (Low)
P5 2 3 2
P2
0 6
P1
11
P4
20
P5
16
11 – 1 = 10
6 – 0 = 6
13 – 1 = 12
20 – 0 = 20
F.T. F.T. F.T.
10 – 5 = 5
6 – 6 = 0
12 – 2 = 10
20 – 4 = 16
Avg. T.A.T. = 62
5
=12.4 ms
Avg. W.T. = 42
5
=8.4 ms
Total 62 ms. 42 ms.
F.T. = Finish Time
P3
13
F.T. F.T.
16 – 2 = 14 14 – 3 = 11
Non –Preemptive Priority
Scheduling
 Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
30
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
P1 0 4 3
P2 2 3 1(Low)
P3 1 7 4 (High)
P4 3 15 2
Avg. T.A.T. = 16 ms
Avg. W.T. = 8.75 ms
Preemptive Priority Scheduling
 If the new process arrived at the ready queue has a higher priority than the currently
running process, the CPU is preempted, which means the processing of the current process
is stopped and the incoming new process with higher priority gets the CPU for its
execution.
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given jobs:
31
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
J1 0 10 3
J2 4 5 0 (High)
J3 3 2 1
J4 5 16 2
J5 2 8 4 (Low)
Preemptive Priority Scheduling
 Solution: Gantt Chart
32
Jobs A.T. B.T. Priority
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
J1 0 10 3
J2 4 5 0 (High)
J3 3 2 1
J4 5 16 2
J5 2 8 4 (Low)
J1
0 3
J1
33
J4
26
33 – 0 = 33
9 – 4 = 5
10 – 3 = 7
26 – 5 = 21
F.T. F.T. F.T.
33 – 10 = 23
5 – 5 = 0
7 – 2 = 5
21 – 16 = 5
Avg. T.A.T. = 105
5
=21 ms
Avg. W.T. = 61
5
=12.2 ms
Total 105 ms. 61 ms.
F.T. = Finish Time
J2
9
F.T. F.T.
41 – 2 = 39 39 – 8 = 31
J3
10
J5
41
J3
4

Recommended for you

Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx

The document discusses process scheduling in operating systems. It covers basic concepts like scheduling criteria, algorithms like FCFS, SJF, priority and round robin scheduling. It explains key process states and scheduling techniques like preemptive and non-preemptive. Examples are provided to illustrate different scheduling algorithms and how they optimize criteria like waiting time, response time and CPU utilization.

CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling

* Using SJF preemptive scheduling: P2 will execute from time 0 to 5 ms. P3 will execute from time 5 to 8 ms. P1 will execute from time 8 to 18 ms. P4 will execute from time 18 to 38 ms. P5 will execute from time 38 to 40 ms. Total waiting time = (10-5) + (8-5) + (18-0) + (38-5) + (40-10) = 5.6 + 3 + 18 + 33 + 30 = 90 Average waiting time = Total waiting time / Number of processes = 90/5 = 5.6 ms * Using Priority preemptive scheduling

cpu schedulingprocess in osscheduling algorithm
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling

The document discusses different CPU scheduling algorithms: 1. First Come First Served scheduling allocates CPU to the longest waiting process first, which can result in longer processes waiting behind shorter ones (convoy effect). 2. Shortest Job First scheduling allocates CPU to the process with the shortest estimated run time, minimizing average wait time. Preemptive SJF allows interrupting the current process if a shorter one arrives. 3. Priority scheduling assigns priority levels and allocates CPU to the highest priority ready process. Preemption and aging policies address starvation of lower priority processes. 4. Round Robin scheduling allocates a time quantum (e.g. 10-100ms) to each ready process

computer science
Preemptive Priority Scheduling
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
33
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
P1 1 5 1 (High)
P2 0 6 2
P3 1 2 1
P4 0 4 3 (Low)
P5 2 3 2
Preemptive Priority Scheduling
 Solution: Gantt Chart
34
Jobs A.T. B.T. Priority
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
P1 1 5 1 (High)
P2 0 6 2
P3 1 2 1
P4 0 4 3 (Low)
P5 2 3 2
P2
0 1
P1
6
P4
20
P5
16
11 – 1 = 10
6 – 0 = 6
13 – 1 = 12
20 – 0 = 20
F.T.F.T. F.T.
10 – 5 = 5
6 – 6 = 0
12 – 2 = 10
20 – 4 = 16
Avg. T.A.T. = 62
5
=12.4 ms
Avg. W.T. = 42
5
=8.4 ms
Total 62 ms. 42 ms.
F.T. = Finish Time
P3
8
F.T. F.T.
16 – 2 = 14 14 – 3 = 11
P2
13
Preemptive Priority Scheduling
 Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process:
35
Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority
P1 0 4 3
P2 2 3 1(Low)
P3 1 7 4 (High)
P4 3 15 2
Avg. T.A.T. = 17 ms
Avg. W.T. = 9.75 ms
Round Robin Scheduling
 Round Robin is the preemptive process scheduling algorithm.
 Each process is provided a fix time to execute called quantum.
 Once a process is executed for given time period. Process is preempted and other process
executes for given time period.
 Context switching is used to save states of preempted processes.
36

Recommended for you

Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin

The document discusses various CPU scheduling algorithms used in operating systems. It describes the main objective of CPU scheduling as maximizing CPU utilization by allowing multiple processes to share the CPU. It then explains different scheduling criteria like throughput, turnaround time, waiting time and response time. Finally, it summarizes common scheduling algorithms like first come first served, shortest job first, priority scheduling and round robin scheduling.

Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering

The document describes CPU scheduling concepts in a multiprogramming operating system. It discusses how CPU scheduling depends on CPU bursts and I/O waits as processes alternate between the two states. The scheduler selects processes from the ready queue to run on the CPU. Scheduling can be preemptive, occurring when a process changes states, or non-preemptive. Common scheduling algorithms like first-come, first-served, shortest job first, priority, and round robin are described. Optimization criteria for scheduling like CPU utilization, throughput, turnaround time and waiting time are also covered.

system modeldeadlock characterizationmethods for handling deadlocks -deadlock prevent
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar

The document discusses various scheduling algorithms: First Come First Served (FCFS), Shortest Job First (SJF), priority scheduling, and round robin (RR). FCFS schedules processes in the order that they arrive. SJF selects the process with the shortest estimated runtime. Priority scheduling prioritizes processes based on assigned priorities. Round robin gives each process a time slice or quantum to use the CPU before switching to another process. Examples are provided to illustrate how each algorithm works.

Round Robin Scheduling
 Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process with Time Slice (Quantum) = 3ms.
37
Jobs Arrival Time (A.T.) Burst Time (B.T.)
P1 1 5
P2 0 7
P3 3 3
P4 2 10
Round Robin Scheduling
 Solution: Gantt Chart Time Slice (Quantum) = 3ms.
38
Jobs A.T. B.T.
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
P1 1 5
P2 0 7
P3 3 3
P4 2 10
P2
0 3
P1
6
P1
17
P2
15
17 – 1 = 16
21 – 0 = 21
12 – 3 = 9
25 – 2 = 23
F.T.F.T. F.T.
16 – 5 = 11
21 – 7 = 14
9 – 3 = 6
23 – 10 = 13
Avg. T.A.T. = 69
4
=17.25 ms
Avg. W.T. = 44
4
=11 ms
Total 69 ms. 44 ms.
F.T. = Finish Time
P4
9
F.T.
P3
12
P4
20
P2
21
P4
24
P4
25
Round Robin Scheduling
 Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for
the given process with Time Slice (Quantum) = 2ms.
39
Jobs Arrival Time (A.T.) Burst Time (B.T.)
P1 1 5
P2 0 3
P3 2 2
P4 3 4
P5 13 2
Round Robin Scheduling
40
Jobs A.T. B.T.
T.A.T.
(F.T. – A.T.)
W.T.
(T.A.T. – B.T.)
P1 1 5
P2 0 3
P3 2 2
P4 3 4
P5 13 2
P2
0 2
P1
4
P1
11
P2
9
16 – 1 = 15
9 – 0 = 9
6 – 2 = 4
13 – 3 = 10
F.T.F.T.F.T.
15 – 5 = 10
9 – 3 = 6
4 – 2 = 2
10 – 4 = 6
Avg. T.A.T. = 40
5
=8 ms
Avg. W.T. = 24
5
=4.8 ms
Total 40 ms. 24 ms.
F.T. = Finish Time
P3
6
F.T.
P4
8
P4
13
P5
15
P1
16
 Solution: Gantt Chart Time Slice (Quantum) = 2ms.
F.T.
15 – 13 = 2 2 – 2 = 0

Recommended for you

CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling

CPU Scheduling is a function on which our operating system word This presentation contain all of the types of scheduling

cpu scheduling and its types
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf

CPU scheduling is the process by which the CPU selects which process to execute next from among processes in memory that are ready to execute. The CPU scheduler selects processes from the ready queue to execute. The goal of CPU scheduling is to maximize CPU utilization and throughput while minimizing waiting time and response time. Common CPU scheduling algorithms include first come first serve (FCF) which services processes in the order they arrive, and shortest job first (SJF) which selects the process with the shortest estimated run time to execute next.

cpu schedulingoperating system
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2

The document discusses operating system concepts including CPU scheduling, process states, and scheduling algorithms. It covers historical perspectives on CPU scheduling and bursts, preemptive vs. nonpreemptive scheduling, and scheduling criteria. Common scheduling algorithms like first-come, first-served (FCFS), shortest-job-first (SJF), priority, and round robin are described. The roles of long-term and short-term schedulers are defined.

Round Robin Scheduling
 Example 2: Five jobs arrive at 0 arrival time the order is given below. Find out Average
Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process with
Time Slice (Quantum) = 10ms.
41
Jobs Burst Time (B.T.)
J1 10
J2 29
J3 3
J4 7
J5 12
Avg. T.A.T. = 35.2 ms
Avg. W.T. = 23 ms
THANK YOU
42

More Related Content

What's hot

Priority scheduling algorithms
Priority scheduling algorithmsPriority scheduling algorithms
Priority scheduling algorithms
Daffodil International University
 
Context switching
Context switchingContext switching
Context switching
DarakhshanNayyab
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
ShubhamGupta345141
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
Multilevel queue scheduling
Multilevel queue schedulingMultilevel queue scheduling
Multilevel queue scheduling
AditiPawaskar5
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
Dr. Loganathan R
 
Semaphore
SemaphoreSemaphore
Semaphore
Arafat Hossan
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Operating System Scheduling Algorithms
Operating System Scheduling AlgorithmsOperating System Scheduling Algorithms
Operating System Scheduling Algorithms
International Institute of Information Technology (I²IT)
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
LECO9
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
Harshith Meela
 
Context Switching
Context SwitchingContext Switching
Context Switching
franksvalli
 
Module 3-cpu-scheduling
Module 3-cpu-schedulingModule 3-cpu-scheduling
Module 3-cpu-scheduling
Hesham Elmasry
 
CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi
SELVI SIVAPERUMAL
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
Binal Parekh
 
System calls
System callsSystem calls
System calls
Bernard Senam
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
Shanu Kumar
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 

What's hot (20)

Priority scheduling algorithms
Priority scheduling algorithmsPriority scheduling algorithms
Priority scheduling algorithms
 
Context switching
Context switchingContext switching
Context switching
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Multilevel queue scheduling
Multilevel queue schedulingMultilevel queue scheduling
Multilevel queue scheduling
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Semaphore
SemaphoreSemaphore
Semaphore
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Operating System Scheduling Algorithms
Operating System Scheduling AlgorithmsOperating System Scheduling Algorithms
Operating System Scheduling Algorithms
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Context Switching
Context SwitchingContext Switching
Context Switching
 
Module 3-cpu-scheduling
Module 3-cpu-schedulingModule 3-cpu-scheduling
Module 3-cpu-scheduling
 
CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
System calls
System callsSystem calls
System calls
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Memory management
Memory managementMemory management
Memory management
 

Similar to CPU Scheduling

Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
Gichelle Amon
 
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 Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
jamilaltiti1
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
Amir Khan
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
sammerkhan1
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
Sonali Chauhan
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
Yogesh Santhan
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
shekhar1991
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
M. Abdullah Wasif
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
A. S. M. Shafi
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
nidsrajdev
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
Harshit Jain
 
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
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
sampledocs2012
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
karthikaparthasarath
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 

Similar to CPU Scheduling (20)

Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
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
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 

Recently uploaded

"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
thanhluan21
 
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
Neny Isharyanti
 
How to Configure Time Off Types in Odoo 17
How to Configure Time Off Types in Odoo 17How to Configure Time Off Types in Odoo 17
How to Configure Time Off Types in Odoo 17
Celine George
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
MichelleDeLaCruz93
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
Celine George
 
Final ebook Keeping the Memory @live.pdf
Final ebook Keeping the Memory @live.pdfFinal ebook Keeping the Memory @live.pdf
Final ebook Keeping the Memory @live.pdf
Zuzana Mészárosová
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
Celine George
 
Webinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional SkillsWebinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional Skills
EduSkills OECD
 
Front Desk Management in the Odoo 17 ERP
Front Desk  Management in the Odoo 17 ERPFront Desk  Management in the Odoo 17 ERP
Front Desk Management in the Odoo 17 ERP
Celine George
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
thanhluan21
 
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
PECB
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
heathfieldcps1
 
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptxChapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Brajeswar Paul
 
L1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 interventionL1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 intervention
RHODAJANEAURESTILA
 
How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17
Celine George
 
Capitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptxCapitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptx
CapitolTechU
 
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Liyana Rozaini
 
No, it's not a robot: prompt writing for investigative journalism
No, it's not a robot: prompt writing for investigative journalismNo, it's not a robot: prompt writing for investigative journalism
No, it's not a robot: prompt writing for investigative journalism
Paul Bradshaw
 

Recently uploaded (20)

"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
 
“A NOSSA CA(U)SA”. .
“A NOSSA CA(U)SA”.                      .“A NOSSA CA(U)SA”.                      .
“A NOSSA CA(U)SA”. .
 
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
Understanding and Interpreting Teachers’ TPACK for Teaching Multimodalities i...
 
How to Configure Time Off Types in Odoo 17
How to Configure Time Off Types in Odoo 17How to Configure Time Off Types in Odoo 17
How to Configure Time Off Types in Odoo 17
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
 
Final ebook Keeping the Memory @live.pdf
Final ebook Keeping the Memory @live.pdfFinal ebook Keeping the Memory @live.pdf
Final ebook Keeping the Memory @live.pdf
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
 
Webinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional SkillsWebinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional Skills
 
Front Desk Management in the Odoo 17 ERP
Front Desk  Management in the Odoo 17 ERPFront Desk  Management in the Odoo 17 ERP
Front Desk Management in the Odoo 17 ERP
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
 
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
AI Risk Management: ISO/IEC 42001, the EU AI Act, and ISO/IEC 23894
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptxChapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
Chapter-2-Era-of-One-party-Dominance-Class-12-Political-Science-Notes-2 (1).pptx
 
L1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 interventionL1 L2- NLC PPT for Grade 10 intervention
L1 L2- NLC PPT for Grade 10 intervention
 
How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17
 
Capitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptxCapitol Doctoral Presentation -June 2024v2.pptx
Capitol Doctoral Presentation -June 2024v2.pptx
 
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)
 
No, it's not a robot: prompt writing for investigative journalism
No, it's not a robot: prompt writing for investigative journalismNo, it's not a robot: prompt writing for investigative journalism
No, it's not a robot: prompt writing for investigative journalism
 

CPU Scheduling

  • 1. CPU SCHEDULING T.Y.B.Sc. (CS) By: Ms. Farhat Rahat Ali Shaikh
  • 2. CONTENTS  Introduction  CPU Scheduling: Dispatcher  Types of CPU Scheduling  Non – Preemptive Scheduling  Preemptive Scheduling  CPU Scheduling: Scheduling Criteria  Scheduling Algorithms  First Come First Serve(FCFS) Scheduling  Shortest-Job-First(SJF) Scheduling  Shortest Remaining Time First (SRTF) Scheduling  Priority Non - Preemptive Scheduling  Priority Preemptive Scheduling  Round Robin(RR) Scheduling 2
  • 3. Introduction  CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold(in waiting state) due to unavailability of any resource like I/O etc., thereby making full use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.  Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The selection process is carried out by the short-term scheduler (or CPU scheduler). The scheduler selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. 3
  • 4. CPU Scheduling: Dispatcher  The dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler. This function involves:  Switching context  Switching to user mode  Jumping to the proper location in the user program to restart that program from where it left last time.  The dispatcher should be as fast as possible, given that it is invoked during every process switch. The time taken by the dispatcher to stop one process and start another process is known as the Dispatch Latency. 4
  • 5. Types of CPU Scheduling  CPU scheduling decisions may take place under the following four circumstances:  When a process switches from the running state to the waiting state (for I/O request or invocation of wait for the termination of one of the child processes).  When a process switches from the running state to the ready state (for example, when an interrupt occurs).  When a process switches from the waiting state to the ready state (for example, completion of I/O).  When a process terminates.  In circumstances 1 and 4, there is no choice in terms of scheduling. A new process(if one exists in the ready queue) must be selected for execution. There is a choice, however in circumstances 2 and 3.  When Scheduling takes place only under circumstances 1 and 4, we say the scheduling scheme is Non-preemptive; otherwise the scheduling scheme is Preemptive. 5
  • 6. Types of CPU Scheduling  Non-Preemptive Scheduling:  In this type of scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.  It is the only method that can be used on certain hardware platforms, because It does not require the special hardware(for example: a timer) needed for preemptive scheduling.  Preemptive Scheduling:  In this type of Scheduling, the tasks are usually assigned with priorities. At times it is necessary to run a certain task that has a higher priority before another task although it is running.  Therefore, the running task is interrupted for some time and resumed later when the priority task has finished its execution. 6
  • 7. CPU Scheduling: Scheduling Criteria  There are many different criteria's to check when considering the "best" scheduling algorithm, they are:  CPU Utilization: To make out the best use of CPU and not to waste any CPU cycle, CPU would be working most of the time(Ideally 100% of the time). Considering a real system, CPU usage should range from 40% (lightly loaded) to 90% (heavily loaded.)  Throughput: It is the total number of processes completed per unit time or rather say total amount of work done in a unit of time. This may range from 10/second to 1/hour depending on the specific processes.  Turnaround Time: It is the amount of time taken to execute a particular process, i.e. The interval from time of submission of the process to the time of completion of the process(Wall clock time).  Waiting Time: It is the total time spent by the process in the ready state waiting to get control on the CPU. 7
  • 8. CPU Scheduling: Scheduling Criteria  Load Average: It is the average number of processes residing in the ready queue waiting for their turn to get into the CPU.  Response Time: Amount of time it takes from when a request was submitted until the first response is produced. Remember, it is the time till the first response and not the completion of process execution(final response).  In general CPU utilization and Throughput are maximized and other factors are reduced for proper optimization. 8
  • 9. Scheduling Algorithms  To decide which process to execute first and which process to execute last to achieve maximum CPU utilization, we have various scheduling algorithms as follows :  First Come First Serve(FCFS) Scheduling  Shortest Job First(SJF) Scheduling  Priority Scheduling  Round Robin(RR) Scheduling 9
  • 10. First Come First Serve(FCFS) Scheduling  In the "First come first serve" scheduling algorithm, the process which arrives first, gets executed first, or we can say that the process which requests the CPU first, gets the CPU allocated first.  It is a Non-preemptive Scheduling algorithm.  Easy to understand and implement.  Its implementation is based on FIFO queue.  Poor in performance as average wait time is high.  This is used in Batch Systems. 10
  • 11. First Come First Serve(FCFS) Scheduling  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given jobs: 11 Jobs Arrival Time (A.T.) Burst Time (B.T.) J1 1 5 J2 0 3 J3 2 2 J4 3 4 J5 2 8
  • 12. First Come First Serve(FCFS) Scheduling  Solution: Gantt Chart 12 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (S.T. – A.T.) J1 1 5 J2 0 3 J3 2 2 J4 3 4 J5 2 8 J2 0 3 J1 8 J3 10 J5 18 J4 22 S.T. F.T. 8 – 1 = 7 3 – 0 = 3 10 – 2 = 8 22 – 3 = 19 18 – 2 = 16 S.T. F.T. S.T. F.T. S.T. F.T. S.T. F.T. 3 – 1 = 2 0 – 0 = 0 8 – 2 = 6 18 – 3 = 15 10 – 2 = 8 Avg. T.A.T. = 53 5 =10.6 ms Avg. W.T. = 31 5 =6.2 ms Total 53 ms. 31 ms. S.T. = Start/Service Time F.T. = Finish Time
  • 13. First Come First Serve(FCFS) Scheduling  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 13 Process Arrival Time (A.T.) Burst Time (B.T.) P1 1 5 P2 0 6 P3 1 2 P4 0 4 Avg. T.A.T. = 11.5 ms Avg. W.T. = 7.2 ms
  • 14. Shortest Job First(SJF) Scheduling  Shortest Job First scheduling works on the process with the shortest burst time or duration first.  This is the best approach to minimize waiting time.  Easy to implement in Batch systems where required CPU time is known in advance.  Impossible to implement in interactive systems where required CPU time is not known.  Processer should know in advance how much time process will take.  It is of two types:  Non Pre-emptive (SJF)  Pre-emptive (SRTF) 14
  • 15. Shortest Job First (SJF) Non - Preemptive  In this type of scheduling CPU allocated to the process(min burst time) cannot be preempted until completes its CPU burst.  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given jobs: 15 Jobs Arrival Time (A.T.) Burst Time (B.T.) J1 0 4 J2 1 1 J3 2 2 J4 3 1
  • 16. Shortest Job First (SJF) Non - Preemptive  Solution: Gantt Chart 16 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (S.T. – A.T.) J1 0 4 J2 1 1 J3 2 2 J4 3 1 J1 0 4 J2 5 J4 6 J3 8 S.T. F.T. 4 – 0 = 4 5 – 1 = 4 8 – 2 = 6 6 – 3 = 3 S.T.F.T. S.T. F.T. S.T. F.T. 0 – 0 = 0 4 – 1 = 3 6 – 2 = 4 5 – 3 = 2 Avg. T.A.T. = 17 4 =4.2 ms Avg. W.T. = 9 4 =2.2 ms Total 17 ms. 9 ms. S.T. = Start/Service Time F.T. = Finish Time
  • 17. Shortest Job First (SJF) Non - Preemptive  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 17 Jobs Arrival Time (A.T.) Burst Time (B.T.) P1 3 5 P2 0 2 P3 4 2 P4 5 3
  • 18. Shortest Job First (SJF) Non - Preemptive  Solution: Gantt Chart 18 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (S.T. – A.T.) P1 3 5 P2 0 2 P3 4 2 P4 5 3 P2 0 2 P1 14 P4 9 P3 6 S.T. F.T. 14 – 3 = 11 2 – 0 = 2 6 – 4 = 2 9 – 5 = 4 S.T.F.T. S.T. F.T.S.T. F.T. 9 – 3 = 6 0 – 0 = 0 4 – 4 = 0 6 – 5 = 1 Avg. T.A.T. = 19 4 =4.75 ms Avg. W.T. = 7 4 =1.75 ms Total 19 ms. 7 ms. S.T. = Start/Service Time F.T. = Finish Time 4 Idle state
  • 19. Shortest Job First (SJF) Non - Preemptive  Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 19 Process Arrival Time (A.T.) Burst Time (B.T.) P1 1.5 5 P2 0 1 P3 2 2 P4 3 4 Avg. T.A.T. = 4.875 ms Avg. W.T. = 1.875 ms
  • 20. Shortest Remaining Time First (SRTF) Preemptive  In Preemptive Shortest Job First Scheduling, jobs are put into ready queue as they arrive, but as a process with short burst time arrives, the existing process is preempted or removed from execution, and the shorter job is executed first.  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given jobs: 20 Jobs Arrival Time (A.T.) Burst Time (B.T.) J1 0 4 J2 1 1 J3 2 2 J4 3 1
  • 21. Shortest Remaining Time First (SRTF) Preemptive  Solution: Gantt Chart 21 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) J1 0 4 J2 1 1 J3 2 2 J4 3 1 J1 0 1 J2 2 J4 5 J3 4 8 – 0 = 8 2 – 1 = 1 4 – 2 = 2 5 – 3 = 2 F.T. F.T. F.T. 8 – 4 = 4 1 – 1 = 0 2 – 2 = 0 2 – 1 = 1 Avg. T.A.T. = 13 4 =3.25 ms Avg. W.T. = 5 4 =1.25 ms Total 13 ms. 5 ms. F.T. = Finish Time J3 3 J1 8 F.T. CPU J1 = J2 = J3 = J4 = 3 => 1 => 2 => 1 => 0 1 => 0 0 0
  • 22. Shortest Remaining Time First (SRTF) Preemptive  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 22 Process Arrival Time (A.T.) Burst Time (B.T.) P1 1.5 5 P2 0 1 P3 2 2 P4 3 4
  • 23. Shortest Remaining Time First (SRTF) Preemptive  Solution: Gantt Chart 23 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) P1 1.5 5 P2 0 1 P3 2 2 P4 3 4 P2 0 1 1.5 P3 4 P3 3 12.5 – 1.5 = 11 1 – 0 = 1 4 – 2 = 2 8 – 3 = 5 F.T. F.T. F.T. 11 – 5 = 6 1 – 1 = 0 2 – 2 = 0 5 – 4 = 1 Avg. T.A.T. = 19 4 =4.75 ms Avg. W.T. = 7 4 =1.75 ms Total 19 ms. 7 ms. F.T. = Finish Time P1 2 P4 8 F.T. CPU P2 = P1 = P3 = P4 = 4.5 => 0 2 => 4 => 0 1 => 0 0 Idle state P1 12.5
  • 24. Shortest Remaining Time First (SRTF) Preemptive  Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 24 Jobs Arrival Time (A.T.) Burst Time (B.T.) P1 3 5 P2 0 2 P3 4 2 P4 5 3 Avg. T.A.T. = 4.5 ms Avg. W.T. = 1.5 ms
  • 25. Priority Scheduling  Priority scheduling is one of the most common scheduling algorithms in batch systems.  Each process is assigned a priority. Process with highest priority is to be executed first and so on.  Processes with same priority are executed on first come first serve basis.  Priority can be decided based on memory requirements, time requirements or any other resource requirement.  It is of two types:  Non – Preemptive Scheduling  Preemptive Scheduling 25
  • 26. Non –Preemptive Priority Scheduling  In case of non – preemptive priority scheduling algorithm if a new process arrives with a higher priority than the current running process, the incoming process is put at the head of the ready queue, which means after the execution of the current process it will be processed.  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given jobs: 26 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority J1 0 10 3 J2 4 5 0 (High) J3 3 2 1 J4 5 16 2 J5 2 8 4 (Low)
  • 27. Non –Preemptive Priority Scheduling  Solution: Gantt Chart 27 Jobs A.T. B.T. Priority T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) J1 0 10 3 J2 4 5 0 (High) J3 3 2 1 J4 5 16 2 J5 2 8 4 (Low) J1 0 10 J2 15 J5 41 J4 33 10 – 0 = 10 15 – 4 = 11 17 – 3 = 14 33 – 5 = 28 F.T. F.T. F.T. 10 – 10 = 0 11 – 5 = 6 14 – 2 = 12 28 – 16 = 12 Avg. T.A.T. = 102 5 =20.4 ms Avg. W.T. = 61 5 =12.2 ms Total 102 ms. 61 ms. F.T. = Finish Time J3 17 F.T. F.T. 41 – 2 = 39 39 – 8 = 31
  • 28. Non –Preemptive Priority Scheduling  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 28 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority P1 1 5 1 (High) P2 0 6 2 P3 1 2 1 P4 0 4 3 (Low) P5 2 3 2
  • 29. Non –Preemptive Priority Scheduling  Solution: Gantt Chart 29 Jobs A.T. B.T. Priority T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) P1 1 5 1 (High) P2 0 6 2 P3 1 2 1 P4 0 4 3 (Low) P5 2 3 2 P2 0 6 P1 11 P4 20 P5 16 11 – 1 = 10 6 – 0 = 6 13 – 1 = 12 20 – 0 = 20 F.T. F.T. F.T. 10 – 5 = 5 6 – 6 = 0 12 – 2 = 10 20 – 4 = 16 Avg. T.A.T. = 62 5 =12.4 ms Avg. W.T. = 42 5 =8.4 ms Total 62 ms. 42 ms. F.T. = Finish Time P3 13 F.T. F.T. 16 – 2 = 14 14 – 3 = 11
  • 30. Non –Preemptive Priority Scheduling  Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 30 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority P1 0 4 3 P2 2 3 1(Low) P3 1 7 4 (High) P4 3 15 2 Avg. T.A.T. = 16 ms Avg. W.T. = 8.75 ms
  • 31. Preemptive Priority Scheduling  If the new process arrived at the ready queue has a higher priority than the currently running process, the CPU is preempted, which means the processing of the current process is stopped and the incoming new process with higher priority gets the CPU for its execution.  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given jobs: 31 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority J1 0 10 3 J2 4 5 0 (High) J3 3 2 1 J4 5 16 2 J5 2 8 4 (Low)
  • 32. Preemptive Priority Scheduling  Solution: Gantt Chart 32 Jobs A.T. B.T. Priority T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) J1 0 10 3 J2 4 5 0 (High) J3 3 2 1 J4 5 16 2 J5 2 8 4 (Low) J1 0 3 J1 33 J4 26 33 – 0 = 33 9 – 4 = 5 10 – 3 = 7 26 – 5 = 21 F.T. F.T. F.T. 33 – 10 = 23 5 – 5 = 0 7 – 2 = 5 21 – 16 = 5 Avg. T.A.T. = 105 5 =21 ms Avg. W.T. = 61 5 =12.2 ms Total 105 ms. 61 ms. F.T. = Finish Time J2 9 F.T. F.T. 41 – 2 = 39 39 – 8 = 31 J3 10 J5 41 J3 4
  • 33. Preemptive Priority Scheduling  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 33 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority P1 1 5 1 (High) P2 0 6 2 P3 1 2 1 P4 0 4 3 (Low) P5 2 3 2
  • 34. Preemptive Priority Scheduling  Solution: Gantt Chart 34 Jobs A.T. B.T. Priority T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) P1 1 5 1 (High) P2 0 6 2 P3 1 2 1 P4 0 4 3 (Low) P5 2 3 2 P2 0 1 P1 6 P4 20 P5 16 11 – 1 = 10 6 – 0 = 6 13 – 1 = 12 20 – 0 = 20 F.T.F.T. F.T. 10 – 5 = 5 6 – 6 = 0 12 – 2 = 10 20 – 4 = 16 Avg. T.A.T. = 62 5 =12.4 ms Avg. W.T. = 42 5 =8.4 ms Total 62 ms. 42 ms. F.T. = Finish Time P3 8 F.T. F.T. 16 – 2 = 14 14 – 3 = 11 P2 13
  • 35. Preemptive Priority Scheduling  Example 3: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process: 35 Jobs Arrival Time (A.T.) Burst Time (B.T.) Priority P1 0 4 3 P2 2 3 1(Low) P3 1 7 4 (High) P4 3 15 2 Avg. T.A.T. = 17 ms Avg. W.T. = 9.75 ms
  • 36. Round Robin Scheduling  Round Robin is the preemptive process scheduling algorithm.  Each process is provided a fix time to execute called quantum.  Once a process is executed for given time period. Process is preempted and other process executes for given time period.  Context switching is used to save states of preempted processes. 36
  • 37. Round Robin Scheduling  Example 1: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process with Time Slice (Quantum) = 3ms. 37 Jobs Arrival Time (A.T.) Burst Time (B.T.) P1 1 5 P2 0 7 P3 3 3 P4 2 10
  • 38. Round Robin Scheduling  Solution: Gantt Chart Time Slice (Quantum) = 3ms. 38 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) P1 1 5 P2 0 7 P3 3 3 P4 2 10 P2 0 3 P1 6 P1 17 P2 15 17 – 1 = 16 21 – 0 = 21 12 – 3 = 9 25 – 2 = 23 F.T.F.T. F.T. 16 – 5 = 11 21 – 7 = 14 9 – 3 = 6 23 – 10 = 13 Avg. T.A.T. = 69 4 =17.25 ms Avg. W.T. = 44 4 =11 ms Total 69 ms. 44 ms. F.T. = Finish Time P4 9 F.T. P3 12 P4 20 P2 21 P4 24 P4 25
  • 39. Round Robin Scheduling  Example 2: Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process with Time Slice (Quantum) = 2ms. 39 Jobs Arrival Time (A.T.) Burst Time (B.T.) P1 1 5 P2 0 3 P3 2 2 P4 3 4 P5 13 2
  • 40. Round Robin Scheduling 40 Jobs A.T. B.T. T.A.T. (F.T. – A.T.) W.T. (T.A.T. – B.T.) P1 1 5 P2 0 3 P3 2 2 P4 3 4 P5 13 2 P2 0 2 P1 4 P1 11 P2 9 16 – 1 = 15 9 – 0 = 9 6 – 2 = 4 13 – 3 = 10 F.T.F.T.F.T. 15 – 5 = 10 9 – 3 = 6 4 – 2 = 2 10 – 4 = 6 Avg. T.A.T. = 40 5 =8 ms Avg. W.T. = 24 5 =4.8 ms Total 40 ms. 24 ms. F.T. = Finish Time P3 6 F.T. P4 8 P4 13 P5 15 P1 16  Solution: Gantt Chart Time Slice (Quantum) = 2ms. F.T. 15 – 13 = 2 2 – 2 = 0
  • 41. Round Robin Scheduling  Example 2: Five jobs arrive at 0 arrival time the order is given below. Find out Average Turn – around time (T.A.T.) and Average Wait time (W.T.) for the given process with Time Slice (Quantum) = 10ms. 41 Jobs Burst Time (B.T.) J1 10 J2 29 J3 3 J4 7 J5 12 Avg. T.A.T. = 35.2 ms Avg. W.T. = 23 ms