OS Scheduler
OS Scheduler
Document Structure
• Objectives
• Introduction
• System Description
• Guidelines
• Grading Criteria
• Deliverables
Objectives
• Evaluating different scheduling algorithms.
Platform Linux
Language C
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
Introduction
A CPU scheduler determines an order for the execution of its scheduled processes; it
decides which process will run according to a certain data structure that keeps track
of the processes in the system and their status.
A process, upon creation, has one of the three states: Running, Ready, Blocked (doing
I/O, using other resources than CPU or waiting on unavailable resource).
A bad scheduler will make a very bad operating system, so your scheduler should be
as much optimized as possible in terms of memory and time usage.
System Description
Consider a Computer with 1-CPU and infinite memory. It is required to make a
scheduler with its complementary components as sketched in the following diagrams.
■ Parent-child relation
■ One-way communication
■ Two-way communication Process
Generator
Scheduler Clock
Page 1 of 6
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
• Ask the user for the chosen scheduling algorithm and its parameters, if there
are any.
• Create a data structure for processes and provide it with its parameters.
• Send the information to the scheduler at the appropriate time (when a process
arrives), so that it will be put it in its turn.
The clock module is used to emulate an integer time clock. This module is already
built for you.
The scheduler is the core of your work, it should keep track of the processes and their
states and it decides - based on the used algorithm - which process will run and for
how long.
You are required to implement the following THREE algorithms...
1. Round Robin (RR).
Page 2 of 6
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
The scheduling algorithm only works on the processes in the ready queue. (Processes
that have already arrived.)
The scheduler should be able to
2. Switch between two processes according to the scheduling algorithm. (Stop the
old process and save its state and start/resume another one.)
3. Keep a process control block (PCB) for each process in the system. A PCB
should keep track of the state of a process; running/waiting, execution time,
remaining time, waiting time, etc.
4. Delete the data of a process when it gets notifies that it finished. When a
process finishes it should notify the scheduler on termination, the scheduler
does NOT terminate the process.
(a) Scheduler.log
(b) Scheduler.perf
Page 3 of 6
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
• You can assume that processes are sorted by their arrival time. Take care that
2 or more processes may arrive at the same time.
• You can use the test generator.c to generate a random test case.
Output Files
scheduler.log example
#At time x pro c ess y s t a t e arr w total z remain y wait k
At time 1 p ro c e s s 1 s t a r t e d arr 1 t o t a l 6 remain 6 wait 0
At time 3 p ro c e s s 1 stopped arr 1 t o t a l 6 remain 4 wait 0
At time 3 p ro c e s s 2 s t a r t e d arr 3 t o t a l 3 remain 3 wait 0
At time 6 pro c es s 2 f i n i s h e d arr 3 t o t a l 3 remain 0 wait 0 TA 3 WTA 1
At time 6 p ro c es s 1 resumed a rr 1 t o t a l 6 remain 4 wait 3
At time 10 pro c e s s 1 f i n i s h e d a rr 1 t o t a l 6 remain 0 wait 3 TA 10 WTA 1 . 67
• You need to stick to the given format because files are compared automatically.
scheduler.perf example
CPU u t i l i z a t i o n = 100%
Avg WTA = 1.34
Avg Waiting = 1 . 5
Std WTA = 0 . 34
• If your algorithm does a lot of processing, processes might not start and stop
at the same time instance. Then, your utilization should be less than 100%.
Page 4 of 6
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
Guidelines
• Read the document carefully at least once.
• You can specify any other additional input to algorithms or any assumption
but after taking permission from your TA.
• Priority values range from 0 to 10 where 0 is the highest priority and 10 is the
lowest priority.
• The measuring unit of time is 1 sec, there are no fractions, so no process will
run for 1.5 second or 2.3 seconds. Only integer values are allowed.
• You can use any IDE (Eclipse, Code::Blocks, NetBeans, KDevelop, CodeLite,
etc.) you want of course, though it would be a good experience to use make
files and standalone compilers and debuggers if you have time for that.
• Spend a good time in design and it will make your life much easier in imple-
mentation.
• The code should be clearly commented and the variables names should be
indicative.
Grading Criteria
• NON compiling code = ZERO grade.
Page 5 of 6
Zewail City of Science and Technology
University of Science and Technology
Communication and Information Engineering Program
Operating Systems (CIE 302)
Deliverables
You should deliver code files, test cases and report containing the following informa-
tion...
• Your assumptions.
• Workload distribution.
• A table for time taken for each task. It will not affect your grade so please be
honest.
Keep the document as simple as possible and do not include unnecessary information
we do not evaluate by word count!
Page 6 of 6