0% found this document useful (0 votes)
10 views8 pages

The Institute of Management Sciences, Lahore: Assignment #2

The document outlines the objectives and types of CPU/process scheduling algorithms for a database and information retrieval course. It explains preemptive and non-preemptive scheduling, along with various scheduling criteria and specific algorithms such as First Come First Serve, Shortest Job First, Shortest Remaining Time First, and Round Robin Scheduling. Additionally, it includes examples of numerical problems related to these scheduling algorithms.

Uploaded by

zunaira shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

The Institute of Management Sciences, Lahore: Assignment #2

The document outlines the objectives and types of CPU/process scheduling algorithms for a database and information retrieval course. It explains preemptive and non-preemptive scheduling, along with various scheduling criteria and specific algorithms such as First Come First Serve, Shortest Job First, Shortest Remaining Time First, and Round Robin Scheduling. Additionally, it includes examples of numerical problems related to these scheduling algorithms.

Uploaded by

zunaira shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

The Institute of Management Sciences, Lahore

Semester Fall-2022
BSCS(HONS)

Course Title: CSC-236 DATABASE AND INFORMATION RETRIEVAL


Course Instructor: Dr.ALI RAZA
RollNo: 211310 Name: ZUNAIRA

ASSIGNMENT #2
CPU/Process Scheduling and Algorithm

Scheduling Objectives:

● Be Fair while allocating resources to the processes.


● Maximize throughput of the system.
● Maximize number of users receiving acceptable response times.
● Be predictable.
● Balance resource use.
● Avoid indefinite postponement.
● Enforce Priorities.
● Give preference to processes holding key resources.
● Give better service to processes that have desirable behavior patterns.

Preemptive Scheduling:

● Preemptive scheduling is used when a process switches from running state


to ready state or from waiting state to ready state.
● The resources (mainly CPU cycles) are allocated to the process for a limited
amount of time and then are taken away, and the process is again placed
back in the ready queue if that process still has CPU burst time remaining.
● That process stays in the ready queue till it gets the next chance to execute.

Non-Preemptive Scheduling:

● Non-preemptive Scheduling is used when a process terminates, or a process


switches from running to waiting state.
● In this scheduling, once the resources (CPU cycles) are allocated to a
process, the process holds the CPU till it gets terminated or it reaches a
waiting state.
● In case of non-preemptive scheduling does not interrupt a process running
CPU in the middle of the execution.
● Instead, it waits till the process completes its CPU burst time and then it can
allocate the CPU to another process.

Scheduling Criteria:

There are several different criteria to consider when trying to select the "best"
scheduling algorithm for a particular situation and environment, including:

Arrival Time: Time at which the process arrives in the ready queue.

Completion Time: Time at which process completes its execution.

Burst Time: Time required by a process for CPU execution.

Turn Around Time: Time Difference between completion time and arrival time.
Turn Around Time = Completion Time – Arrival Time

Waiting Time(W.T): Time Difference between turnaround time and burst time.
Waiting Time = Turn around Time – Burst Time.
Types of Scheduling Algorithm

1. First Come First Serve (FCFS):

In FCFS Scheduling

● The process which arrives first in the ready queue is firstly assigned the
CPU.
● In case of a tie, a process with a smaller process id is executed first.
● It is always non-preemptive in nature.
● Jobs are executed on a first come, first serve basis.
● It is a non-preemptive, preemptive scheduling algorithm.
● Easy to understand and implement.
● Its implementation is based on the FIFO queue.
● Poor in performance as average wait time is high.

2. Shortest Job First (SJF):

● Processes which have the shortest burst time are scheduled first.
● If two processes have the same bust time, then FCFS is used to break the tie.
● This is a non-pre-emptive, preemptive scheduling algorithm.
● 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.
● The processor should know in advance how much time the process will take.

3. Shortest Remaining Time First (SRTF):

● Pre-emptive mode of Shortest Job First is called Shortest Remaining Time


First (SRTF).
4. Robin Scheduling Round:

● CPU is assigned to the process on the basis of FCFS for a fixed amount of
time.
● This fixed amount of time is called a time quantum or time slice.
● After the time quantum expires, the running process is preempted and sent to
the ready queue.
● Then, the processor is assigned to the next arriving process.
● It is always preemptive in nature.
PROCESS SCHEDULING ALGORITHM NUMERICAL PROBLEMS

EXAMPLES
1. First Come First Serve (FCFS):
2. Shortest Job First (SJF):
3. Shortest Remaining Time First (SRTF):

4. Robin Scheduling Round:

You might also like