Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

ITU07202/ITU07210/CSU07210- OPERATING SYSTEMS TUTORIAL TWO

1. Using the process state diagrams of Figure 1, explain why there’s no transition:
a. From the READY state to the WAITING state
ANSWER

From the READY state to the WAITING state: This is because the READY state
represents processes that are ready to execute, but are waiting for CPU time. They are not blocked
or waiting for any resource. The WAITING state, on the other hand, represents processes that are
waiting for some event or resource to become available. Therefore, there is no direct transition
from the READY state to the WAITING state.

Figure 1: Five state process model

b. From the WAITING state to the RUNNING state


ANSWER

This is because a process in the WAITING state is blocked, waiting for some resource or
event to occur. When that resource or event becomes available, the process transitions to the
READY state, and it's up to the scheduler to decide when to allocate CPU time to it, and hence
move it to the RUNNING state
2. Explain with diagram the process states?
❖ A process goes through various states during its lifetime. The process states diagram is a
visual representation of these states. The most common states are:
NEW: The process is being created or initialized.
READY: The process is waiting for CPU time to be allocated.
RUNNING: The process is currently being executed by the CPU.
WAITING: The process is waiting for some event or resource to become available.
TERMINATED: The process has completed its execution and is about to be terminated.
A process can also be in other states, such as SUSPENDED or BLOCKED, depending on the
operating system and its implementation.

3. Describe the information in the Process Control Block (PCB)?


A Process Control Block (PCB) is a data structure that contains information about a
process. It is created by the operating system when a process is created and is stored in memory.
The information contained in a PCB includes:
Process ID (PID): A unique identifier assigned to each process by the operating system.
Process state: The current state of the process, such as RUNNING, READY, or
WAITING.
CPU registers: The values of the CPU registers of the process, including the program
counter and stack pointer.
Memory management information: Information about the memory used by the process,
such as its base address and limit.
I/O status: Information about I/O operations being performed by the process, such as the
device being used and the current status of the operation.
Accounting information: Information about the resources used by the process, such as
CPU time used and memory usage.
The PCB is used by the operating system to manage and control processes. When a
process is scheduled for execution, the operating system loads the relevant information from its
PCB into the CPU registers.

4. Use the given information in figure 2 to answer following questions ;

Figure 2

Draw a timeline for each of the following scheduling algorithms. (It may behelpful to first
compute a start and finish time for each job.)
a) FCFS

0 10 22 25 26 41

A B C D E

IN ADDITION
JOB ARRIVAL CPU COMPLETION TURN WAITING RESPONSE
AROUND TIME(W.T) TIME
TIME CYCLE TIME (CT)
TIME
WT=T.A.T –
Time the (T.A.T)
Busting
process
T.A.T=CT tine/cpu
finished look
– A.R cycle/execution
on the graph
A 0 10 10 10 0 0
B 2 12 22 20 8 8
C 3 3 25 23 20 22
D 6 1 26 20 19 25
E 9 15 41 32 17 26
AVERAGE TURNAROUND TIME =10 + 20+23+20+32/5
AVERAGE WAITING TIME = 0+8+20+19+17/5
NOTE FOR NON PREEMPTIVE, WAITING TIME = RESPONSE TIME BUT NOT FOR
PREEMPTIVE POLICY

b) SJN
0 3 6 7 14 26 41

A C D A B E
c) SRT
0 3 6 7 14 26 41

A C D A B E

d) Round robin (using a time quantum of 5, ignore context switching and natural
wait)
0 5 10 13 14 19 24 29 34 36 41

A B C D E A B E B E

5. What is the difference between CPU-bound process and I/O-bound process?


ANSWER
A CPU-bound process is a process that spends most of its time doing computations, such
as complex mathematical operations, data analysis, or scientific simulations. CPU-bound
processes require more CPU time and fewer I/O operations.
In contrast, an I/O-bound process is a process that spends most of its time waiting for
input/output operations to complete, such as reading or writing to a disk, network communication,
or user input. I/O-bound processes require more I/O operations and less CPU time.

6. Draw and explain the differences between two, five and seven process state diagrams.
A process is a program in execution and it is more than a program code called as text section and
this concept works under all the operating system because all the task perform by the operating
system needs a process to perform the task
The process executes when it changes state. The state of a process is defined by the current
activity of the process. It is important to know that only one process can be running on any
processor at any instant. Many processes may be ready and waiting.
Two-State Process Model
The simplest model in the process state will be a two-state model as it consists of only two states
that are given below:
Running State- A state in which the process is currently being executed.
Not Running State- A state in which the process is waiting for execution.

Five state process Model


The states present in the 5-state model are as follows −
New − When a new process is created, It enter into the new state. Then it tries to load into
RAM.
Ready − The processes that are loaded on RAM and waiting for CPU are in ready state.
Running − The processes that are running on the CPU are in running state.
If the process is running in its critical section, then other processes need to wait in the
ready state.
Blocked − All processes that are leaving the CPU and moving to the waiting state are in
the blocked state. When the CPU becomes free, processes from the blocked state again move to
the ready state, and from ready to Running state.
Exit / Terminated − A process that is terminated from CPU and RAM is in the terminate
state.
Seven state process model
The states present in seven state models are as follows −
New − Contains the processes that are newly coming for execution.
Ready − Contains the processes that are present in main memory and available for
execution.
Running − Contains the process that is running or executing.
Exit − Contains the processes that complete its execution.
Blocked − Contains the processes that are present in main memory and awaiting an event
to occur.
Blocked Suspend − It contains the process present in secondary memory and awaits an
event to occur.
Ready Suspend − Contains the processes that are present in secondary memory but is
available for execution as soon as it is loaded into main memory.
The pictorial representation of seven state model is shown below −
So the difference between these five and seven models is of two states which are not
present in five states but present in seven states and they are Suspended ready and
Suspended while in state model there only two states

7. Find the average waiting time and average turnaround time for executing the following
processes using the following scheduling algorithms :

a) FCFS

b) SJF SO NOW YO SOLVE THIS

c) SRTF
d) Round robin (quantum = 4)

You might also like