AACS2284 Tutorial 2
AACS2284 Tutorial 2
Q1. (a) Describe the term “process” in the context of operating systems.
- A process is defined as an entity which represents the basic unit of work to be
implemented in the system.
- A process is a ‘task’ or ‘job’ that an individual program has pushed to the CPU
(the executable program)
- It is allotted a set of resources (registers, program counter and data section) and
will encompass one or more threads.
- Each process in the OS is represented by a PCB repository for information such
as Process identification, Process status (HOLD, READY, RUNNING,
Waiting), process state etc. PCB’s content varies from process to process
(b) Elaborate how context switch enables multiple processes to share a single processor.
- The job will be placed in process queue based on each job’s characteristics and
the jobs will be assigned into CPU to be processed. The job will be moved back
to ready queue when the CPU time is finished and assigned to CPU again when
the CPU is free. The job will be terminated when it is concluded.
Page 1 of 10
AACS2284 Operating Systems
Q3. (a) With the aid of a diagram, explain how a process may switch among the different states.
from its creation to termination
(b) Identify the event that will switch a process from running state to ready state and from
running state to waiting state.
- RUNNING to READY: time interrupt, higher priority process gets ready for
execution
- RUNNING to WAITING: I/O request, wait for a message or some action
from another process.
Q4. Identify the level (short-term, medium-term, long-term) of scheduler that would make a decision
on each of the following situation. Justify your answer.
(i) Which temporarily suspended process should be activated in order to balance the
process mix?
Medium-term scheduler: determines when processes are to be suspended and
resumed.
(ii) Which ready process should be assigned the CPU when it next becomes available?
Short term scheduler (Process Scheduler): Determines which of the ready
processes can have CPU resources and for how long.
(iii) Which of a series of waiting batch jobs that have been spooled to disk should next be
initiated?
Long-term scheduler (Job Scheduler): determines which programs are admitted
to the system for execution and when, which ones should be exited.
Page 2 of 10
AACS2284 Operating Systems
Q5. (a) Consider the following set of processes, with the length of the CPU burst given in
milliseconds (ms). Ignore no context switch time.
Draw a Gantt chart illustrating the execution of the above processes, and calculate the
average turnaround time and average waiting time based on each of the following
algorithms:
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
P1 0 3 3 0 3
P2 2 6 11 3 9
P3 3 2 5 0 2
P4 6 4 18 8 12
P5 9 3 14 2 5
Average 2.6 6.2
Turnaround Time
= ((3-0) + (11-2) + (5-3) + (18-6) + (14-9)) / 5
= 31 / 5
= 6.2
Page 3 of 10
AACS2284 Operating Systems
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
P1 0 3 3 0 3
P2 2 6 18 10 16
P3 3 2 5 0 2
P4 6 4 10 0 4
P5 9 3 13 1 4
Average 2.2 5.8
Turnaround Time
= ((3-0) + (18-2) + (5-3) + (10-6) + (13-9)) / 5
= 29 / 5
= 5.8
(iii) Preemptive Priority (Assume that a larger priority number implies a higher priority)
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
P1 0 3 18 15 18
P2 2 6 17 9 15
P3 3 2 5 0 2
P4 6 4 13 3 7
P5 9 3 12 0 3
Average 5.4 9.0
Turnaround Time
= ((18-0) + (17-2) + (5-2) + (13-6) + (12-9)) / 5
= 45 / 5
= 9.0
Page 4 of 10
AACS2284 Operating Systems
(iv) Non-Preemptive Priority (Assume that a smaller priority number implies a higher priority)
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
P1 0 3 3 0 3
P2 2 6 9 1 7
P3 3 2 11 6 8
P4 6 4 15 5 9
P5 9 3 18 6 9
Average 3.6 7.2
Turnaround Time
= ((3-0) + (9-2) + (11-3) + (15-6) + (18-9)) / 5
= 36 / 5
= 7.2
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
P1 0 3 3 0 3
P2 2 6 14 6 12
P3 3 2 8 3 5
P4 6 4 18 8 12
P5 9 3 17 5 8
Average 4.4 8.0
Turnaround Time
= ((3-0) + (14-2) + (8-3) + (18-6) + (17-9)) / 5
= 40 / 5
= 8.0
Page 5 of 10
AACS2284 Operating Systems
(b) State why strict non-preemptive scheduling is unlikely to be used in a computer center.
- If non-preemptive scheduling is used in a computer center, a process is capable of keeping
other processes waiting for a long time.
- Higher priority processes have to wait the current process finish it’s execution
and may not to minimize the average waiting time in a computer center.
(c) Is round robin algorithm suitable for interactive systems? State TWO (2) reasons to support
your answer.
- Yes, Round Robin algorithm is suitable for interactive systems
- It provides reasonable response time to interactive users
- It provides fair CPU allocation
Page 6 of 10
AACS2284 Operating Systems
Self-Review
Q1. Consider the list of processes that going to execute as shown in Table 1:
By referring to Table 1, draw a timeline for each of the following algorithms and
calculate the Average Waiting Time and Average Turnaround Time for each of the
algorithms:
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 3 3 0 3
B 2 6 9 1 7
C 5 2 12 5 7
D 7 1 10 2 3
E 9 4 16 3 7
Average 2.2 5.4
Turnaround Time
= ((3-0) + (9-2) + (12-5) + (10-7) + (16-9)) / 5
= 27 / 5
= 5.4
Page 7 of 10
AACS2284 Operating Systems
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 3 3 0 3
B 2 6 12 4 10
C 5 2 7 0 2
D 7 1 8 0 1
E 9 4 16 3 7
Average 1.4 4.6
Turnaround Time
= ((3-0) + (12-2) + (7-5) + (8-7) + (16-9)) / 5
= 23 / 5
= 4. 6
(c) Non-Preemptive Priority (Assume that a larger priority implies a higher priority
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 3 3 0 3
B 2 6 9 1 7
C 5 2 15 8 10
D 7 1 16 8 9
E 9 4 13 0 4
Average 3.4 6.6
Turnaround Time
= ((3-0) + (9-2) + (15-5) + (16-7) + (13-9)) / 5
= 33 / 5
= 6.6
Page 8 of 10
AACS2284 Operating Systems
Q2. Consider the list of processes to be performed by processor shown in the Table 2:
Draw a timeline for each of the following algorithms and calculate the Average Waiting
Time and Average Turnaround Time for each of them:
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 6 6 0 6
B 1 4 10 5 9
C 7 3 14 4 7
D 9 1 11 1 2
Average 2.5 6.0
Turnaround Time
= ((6-0) + (10-1) + (14-7) + (11-9)) / 4
= 24 / 4
= 6.0
Page 9 of 10
AACS2284 Operating Systems
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 6 10 4 10
B 1 4 5 0 4
C 7 3 14 4 7
D 9 1 11 1 2
Average 2.25 5.75
Turnaround Time
= ((10-0) + (5-1) + (14-7) + (11-9)) / 4
= 23 / 4
= 5.75
Job Arrival Time CPU cycle Finish Time Wait time Turnaround time
A 0 6 9 3 9
B 1 4 10 5 9
C 7 3 13 3 6
D 9 1 14 4 5
Average 3.75 7.25
Turnaround Time
= ((9-0) + (10-1) + (13-7) + (14-9)) / 4
= 29 / 4
= 7.25
Page 10 of 10