You are on page 1of 11

Assignment No.

3
Course: Operating System
Submitted by:
Name Roll No
Wardah Saleem F-101032
Sara Najam F-101046

Q.No.1: Answer the following questions briefly (maximum 3 lines);

1. What is the CPU-I/O Burst Cycle?


CPU burst :
It is when the process is being executed in the CPU. I/O burst is when the CPU is waiting for
I/O for further execution. After I/O burst, the process goes into the ready queue for the
next CPU burst.

2. What is the function of the short-term scheduler?


short-term scheduler:
 It is also known as the CPU scheduler decides which of the ready, in-memory processes is to
be executed (allocated a CPU) after a clock interrupt etc.

3. Which type of scheduler performs the process swapping from RAM to Hard drive?
Medium-term scheduling performs the process swapping from RAM to Hard Drive.

4. What is meant by multitasking and multiprocessing?


Multiprogramming:
 A computer running more than one program or multiple programs at a time.
 Multitasking:
Tasks sharing a common resource .

5. What is a non-preemptive scheduling scheme?


 Non-preemptive Scheduling:
It  is used when a process terminates, or a process switches from running to waiting state.

6. What is a preemptive scheduling scheme?


Preemptive scheduling:
It  is used when a process switches from running state to ready state or from waiting state to
ready state.

7. What are the 5 basic states of a process?


 NEW
 READY
 RUNNING
 WAITING
 TERMINATING

8. What happens to a process in the new state?


NEW :
The process is being created. 

9. What happens to a process in the running state?


Running:
A process moves into the running state when it is chosen for execution.

10. What happens to a process in the waiting state?


Process moves into the waiting state if it needs to wait for a resource, such as waiting for
user input etc.

11. What happens to a process in the ready state?


Ready:
A "ready" process has been loaded into main memory and is awaiting execution on a CPU 

12. What happens to a process in the terminated state?


Terminated State:
 The process has finished execution. In this state a process is unable to run until some
external event happens.

13. The scheduling decision to switch from running to waiting state is preemptive or non-
preemptive?
Non-preemptive Scheduling is used when a process terminates, or a process switches
from running to waiting state.

14. The scheduling decision to switch from running to ready state is preemptive or non-
preemptive?
Preemptive scheduling is used when a process switches from running state to ready state or
from waiting state to ready state.

15. The scheduling decision to switch from waiting to ready state is preemptive or non-
preemptive?
Preemptive scheduling is used when a process switches from running state to ready state or
from waiting state to ready state.

16. The scheduling decision to terminate is preemptive or non-preemptive?


Non-preemptive scheduling decides that the CPU is allocated to the process till
it terminates or switches to waiting state.

17. What is the function of the dispatcher module?


The main function of the dispatcher is assigns ready process to the CPU. CPU-
scheduling function is the dispatcher, which is the module that gives control of the CPU to
the process selected by the short-term scheduler.

18. What is the dispatch latency?


The term dispatch latency describes the amount of time it takes for a system to respond to a
request for a process to begin operation.

19. What is the CPU utilization?


CPU utilization is the sum of work handled by a Central Processing Unit. It is also used to
estimate system performance.

20. Do we want to maximize or minimize the CPU utilization?


CPU utilization varies depending on the amount and type of managed computer tasks. There
are some tasks which require heavy CPU time, while others require less because of non-
CPU resource requirements. So it depends on the task that whether we have to maximize or
minimize the CPU utilization.

21. What is the throughput?


Throughput is the rate of production or the rate at which something is processed ,
throughput is a measure of how many units of information a system can process in a given
amount of time.
22. Do we want to maximize or minimize the throughput?
We need to maximize throughput so that the number of jobs processed per time unit or
multiple tasks will be processed per unit time

23. What is the turnaround time?


Turnaround time (TAT) means the amount of time taken to complete a process or fulfill a
request. 

24. Do we want to maximize or minimize the turnaround time?


Time Difference between completion time and arrival time. So turnaround must be
minimized so that time difference will be less and process will be completed as soon as
possible.

25. What is the waiting time?


 Waiting Time:
It is the term that is used to refer to the time that a machine or its operators remain idle.

26. Do we want to maximize or minimize the waiting time?


We want to minimize the waiting time so that process in queue don’t have to wait long for
their execution.

27. What is the response time?


Response time is the time a system or functional unit takes to react to a given input.

28. Do we want to maximize or minimize the response time?


We need to minimize the response time so that user will get its desired input in less time

29. What is the FCFS (First Come First Serve) Scheduling Algorithm?
First Come First Serve (FCFS) is an operating system scheduling algorithm that automatically
executes queued requests and processes in order of their arrival.
30. Is FCFS (First Come First Serve) preemptive or non-preemptive?
FCFS is a non-preemptive scheduling algorithm. First come first serve scheduling
algorithm states that the process that requests the CPU first is allocated the CPU first. It
is implemented by using the FIFO queue. When a process enters the ready queue, its PCB
is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at
the head of the queue.

Q.No.2: Consider the following processes with CPU burst time, priority and
arrival time;

Process Burst Time Priority Arrival Time


P1 10 3 0
P2 1 1 0
P3 2 5 0
P4 1 4 0
For the set of processes directly above, draw a Gantt chart for the FCFS and
Round Robin Scheduling Algorithm. Calculate waiting time and turnaround time
for the processes.

FCFS:
Criteria: lower number Higher Priority
Process Burst Time Priority Arrival Time Completion Turn Around Waiting Time
time Time
T.A= C.T – A.T W.T= T.A – B.T
P1 10 3 0 9 9 1
P2 1 1 0 1 1 0
P3 2 5 0 12 12 10
P4 1 4 0 10 10 9

As, the arrival time of the processes is zero. So, the


completion time and turn around time will be same.
Gant Chart:
P2 P1 P4 P3
0 1 9 10 12

ROUND ROBIN SCHEDULING:


Quantum time = 2
Process Burst Time Priority Arrival Time Completion Turn Around Waiting Time
time Time
T.A= C.T – A.T W.T= T.A – B.T
P1 10 8 0 3 0 14 14 4
P2 1 0 1 0 1 1 0
P3 2 0 5 0 6 6 4
P4 1 0 4 0 4 4 3

As, the arrival time of the processes is zero. So, the completion time and
turn around time will be same.

Gant Chart:
Ready queue:
P2 P1 P4 P3 P1

Running queue:
P2 P1 P4 P3 P1
0 1 3 4 6 14

Q.No.3: Write the C++ program for the processes in Q.No.2 using FCFS
Scheduling Scheme. Also calculate the average waiting time and
average turnaround time.

C++ code:
Output:
________________________________________________________

You might also like