0% found this document useful (0 votes)
2 views

Chap #2 -Process Managment Operating system

The document provides an overview of process management, defining key concepts such as processes, threads, and their differences. It explains the various states of a process, the process control block, scheduling queues, and process scheduling techniques. Additionally, it outlines criteria for evaluating CPU scheduling algorithms and describes relevant terms like turnaround time, response time, and waiting time.

Uploaded by

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

Chap #2 -Process Managment Operating system

The document provides an overview of process management, defining key concepts such as processes, threads, and their differences. It explains the various states of a process, the process control block, scheduling queues, and process scheduling techniques. Additionally, it outlines criteria for evaluating CPU scheduling algorithms and describes relevant terms like turnaround time, response time, and waiting time.

Uploaded by

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

Unit # 2 : Process Management (12)

Q: – What is a Process?

Ans: Process:
A program in execution is called process. A process is considered as an activity to perform a
task.
A program does not perform any action itself. When a program runs on the computer, it
performs an action. So a program in execution is called a process. It means that a program becomes
a process when it is loaded into the memory for execution. It refers to an executing set of machine
instructions.
The main difference between process and program is that a process is an active entity, while a
program is a static entity (passive entity) stored in a file (executable file) on the disk.

A process includes the following information:


 Program Code: It is a part of program (or set of instructions). It is used to perform an
activity. It is sometimes known as Text Section.
 Stack: It contains temporary data for the process. For example, it contains
parameters of procedures, return address, and local variables.
 Program Counter: It keeps track of the address of the next instruction to be executed in
memory. The current activity of the process is represented by
current values of program counter.
 Data: It contains global variables.
 Heap: It is a memory space that is dynamically allocated during process
execution

Q: – What is a Thread?

Ans: A thread is a basic unit of CPU utilization. It is also called a lightweight process. It is
sequence of instructions within a process. It behaves like a process but it does not its own PCB
(Process Control Block). Usually, multiple threads are created within a process. Multiple
threads in a process allow multiple execution simultaneously.

A thread consists of the followings:


 Thread ID.
 Program Counter
 Register Set
 Stack.

Thread Shares with its Peer threads:


 Code Section
 Data Section
 Any Operating System Resources, which are available to the task.
Unit # 2 : Process Management (13)

Benefits of threads:
 Threads share common data, no need to use IPC.
 Threads can take advantages of multiprocessors.
 There is a high throughput when multiple threads cooperate in a single job.
 Threads are cheap to create, as they only need a stack and storage for register.
 Threads use very little resources of an operating system.

Multithreading:
Multithreading allows OS to execute different threads simultaneously. An Application is
implemented as separate process with several threads.
For Example: A web browser is an application. It can use one thread to display images and
second thread to retrieve data from the network.

Q: – What is difference between process and threads?

Ans: Followings are the primary differences between process and threads
 Process means a program is in execution, whereas thread means a segment of a process.
 A Process is not Lightweight, whereas Threads are Lightweight.
 Process takes more time for creation, whereas Thread takes less time for creation
 A Process takes more time to terminate, and the thread takes less time to terminate.

Q: – Describe different states of process.

Ans: Process States:


The state of process describes the nature of the current activity in a process. In computer
system, a process changes states during execution. Various events can cause a process to change
states.

In short term scheduling, a process exists in one of the five states:

i. New: This state of process indicates that the process is newly created and is not yet
in memory.
ii. Blocked: In this state, the process is blocked and is waiting for some event to occur
before it can continue execution. For example, it is waiting for the completion
of an I/O operation. This state of process is also known as waiting state.
iii. Ready: In this state, the process is yet not allocated to the processor for running,
however it is ready to run.
iv. Running: In this state, the process is executing (running) on the processor.
v. Terminated: In this state, the process has finished its execution on the CPU.
Unit # 2 : Process Management (14)

Medium-term scheduling adds two additional process states:

 Swapped-Blocked: A process that is waiting for some event to occur and has been swapped out
to secondary storage.
 Swapped-Ready: A process that is ready to run but is swapped out to secondary storage. A
swapped-ready process may not be allocated to the CPU since it is not in
main memory.
Long-term scheduling adds two additional process states:

 Held: A process that has been created but will not be considered for loading into memory or for
execution. Typically only new processes can become held process. Once a process leaves the
held state, it does not return to it.

Q: – Draw and explain process state transition diagram.

Ans: There are four major states of a process that are Blocked, Ready, Running and Terminated.
Usually, a process transits (moves) from one state to another.

Different state of transitions in a process can be as follows:


1. Running - Blocked Transition
2. Running - Ready Transition
3. Ready - Running Transition
4. Blocked - Ready Transition
Unit # 2 : Process Management (15)

5. Running - Terminated Transition

1) Running - Blocked Transition


This transition is made when a running process must execute a system call such as for performing
I/O operation, communicating with other processes etc. In such cases, running process must be
blocked. Another example is when a process needs input that is not yet available, the process is
automatically blocked.

2) Running - Ready Transition


This transition is made when the scheduler decides that the running process has used its time
slice (allocated time to the process). It moves the process from running state to the ready state and
control is given to another process.

3) Ready - Running Transition


This transition is made when CPU scheduler selects a process for running from the ready queue
and sends to the CPU for execution.
4) Blocked - Ready Transition:
This transition is made when a process is moved from blocked state to ready state. If no other
process is running at that instant, transition 3(Ready  Running) will be triggered immediately.

5) Running - Terminated Transition


This transition is made when a running process is terminated. A process may be terminated by
either performing some illegal action or by completing its own execution.

Q: – What is Process Control Block. Which type of information it holds?

Ans: Process Control Block:


Process control block is a data structure. It contains all information for a process to be used
for controlling its execution. It also contains the information related to resource allocated to the
process. It is also known as Task Control Block. It is the central store of information that allows the
Unit # 2 : Process Management (16)

operating system to locate all the key information about a process. When CPU switches from one
process to another, the operating system uses the related PCB to save the current state of process and
use this information when control returns back. Information in PCB is updated during the transition
of process state. When the process is terminated the PCB is deleted from memory.

The information that must be saved in PCB, usually consists of the following:

i. Process State:
It indicates the information about state of the process. The state can be ready, waiting, etc.

ii. Process Counter:


It points to the next instruction to be executed when the process gains the CPU.

iii. CPU Register:


It indicates the information about the contents of CPU register for the process. The
information of CPU register must be saved when an interrupt occurs, so that the process can be
contained correctly afterward.

iv. CPU Scheduling:


It holds information needed for CPU scheduling, such as process priority and any scheduling-
queue pointers.

v. Memory Management:
It is the information required by the memory manager such as base register, limit register,
page table for the process etc.

vi. Accounting Information:


This part of PCB holds the amount of CPU time and real time used by the process to date, the
process number, and so forth.

vii. I/O Status Information :


This part of the PCB holds a list of the I/O devices that the process has requested, a list of the
process's open files, etc.

Q: – Describe Scheduling Queues.

Ans: The most common types of queues and their purpose are as follows:

 Job Queue:
Each entering process goes into job queue. The processes in job queue reside on secondary
storage and await the allocation of main memory.
Unit # 2 : Process Management (17)

 Ready Queue:
The set of all processes that are in main memory and are waiting for CPU time are kept in ready
queue.

 Waiting Queues:
The set of processes waiting for allocation of certain I/O devices, are kept in waiting queue.

Q: – Describe process scheduling.

Ans: Process Scheduling:


Scheduling is used to determine which process to run first and for how many time. The
method or procedure to schedule the processes to execute on the CPU is called process scheduling.
Basically process scheduling is a technique that is used when there are limited resources
and many processes are competing for them. In multiprocessing systems, scheduling is used to
determine which process is given control of CPU.

Scheduler:
The part of operating system which schedules the processes is called scheduler. The
scheduler selects a process (according to some criteria) from the ready queue and allocates the
CPU to that process.

Types of Scheduling/Scheduler:
o Long-Term Scheduler
o Short-Term Scheduler
o Medium-term Scheduler

 Long-Term Scheduler:
Long-term scheduler is also known as Job Scheduler. Long term scheduler determines which
programs are to be admitted to the system for processing. It selects jobs or user programs from job
queue on the disk and loads them into main memory. Once a job or user program is loaded into
memory, it becomes the process and is added to the ready queue in memory. If too many processes
are loaded into memory, the system may slow down. The long-term scheduler controls the number of
processes in memory which is known as the degree of multiprogramming.
If the degree of multiprogramming is stable, then the average rate of processes creation must
be equal to the average departure rate of processes leaving the system. When a process leaves the
system, the long-term scheduler performs its function. It decides which processes should be selected
for execution. For this purpose, the long-term scheduler may spend comparatively a long time for
making decision.

 Medium Term Scheduler:


Unit # 2 : Process Management (18)

Medium-term scheduling is also known as swapping. In this type of scheduling, swapper is


used to exchange processes between main memory and secondary storage (disk). It removes the
process temporarily from the main memory and places them on secondary storage. It moves it back
to main memory when required. Typically, multiprocessing systems use swapping technique which
is commonly known as swapping out and swapping in. Sometimes, a process that is in job queue on
disk is too long and cannot fit in memory, then swapper removes another process (or multiple
processes) from ready queue to make room for it. Later, the same process is re-loaded into memory,
which is added to the ready queue and its execution is continued where it was left off. If a process is
waiting for completion for a short term I/O operation, then it is not swapped out.

 Short-Term Scheduler:
Short-term scheduler is also known as dispatcher. It selects a process from the ready queue
and allocates CPU to that process for execution. The process state is changed from ready to running.
Typically, the short-term scheduler gives the control to CPU for a short period (fixed maximum
amount time) of time. A process is moved back to ready queue after the given time is over. It may be
executed for only a few milliseconds, and then the next process is selected from ready queue for
execution. Thus short-term scheduler makes scheduling decision much more frequently than the
long-term and medium-term schedulers.

Q: – What is a process scheduling criteria? Also list out scheduling criteria with short description.

Ans: Different CPU scheduling algorithms have different properties and the choice of a particular
algorithm depends on the various factors. Many criteria have been suggested for comparing CPU
scheduling algorithms.

The criteria include the following:


1. CPU utilization:
The main objective of any CPU scheduling algorithm is to keep the CPU as busy as possible.
Theoretically, CPU utilization can range from 0 to 100 but in a real-time system, it varies from 40 to
90 percent depending on the load upon the system.

2. Throughput:
A measure of the work done by CPU is the number of processes being executed and
completed per unit time. This is called throughput. The throughput may vary depending upon the
length or duration of processes.

3. Balanced Utilization:
Balanced utilization means all available resources are utilized in such a way that the load on
all resources remains balanced. There should not arises a situation where certain resources are
heavily loaded, while the others are sitting idle. Therefore, addition to considering the CPU
Unit # 2 : Process Management (19)

utilization, the utilization of memory, I/O devices and other system resources is equally important.

4. Turnaround Time:
For a particular process, an important criteria is how long it takes to execute that process. The
time elapsed from the time of submission of a process to the time of completion is known as the
turnaround time. Turn-around time is the sum of times spent waiting to get into memory, waiting in
ready queue, executing in CPU, and waiting for I/O.

5. Waiting Time:
A scheduling algorithm does not affect the time required to complete the process once it
starts execution. It only affects the waiting time of a process i.e. time spent by a process waiting in
the ready queue.

6. Response Time:
In an interactive system, turn-around time is not the best criteria. A process may produce
some output fairly early and continue computing new results while previous results are being output
to the user. Thus another criteria is the time taken from submission of the process of request until the
first response is produced. This measure is called response time.

7. Predictability
Predictability represents the consistency in the average response time in interactive system. It
is another measure of performance of a system because all users Prefer consistency. Consider an
interactive system that normally responds within a microsecond but on some occasions, it takes 5 to
15 milliseconds or more. Thus the user may be over this behavior. Most of the users prefer a system
with reasonable and predictable response time, over a system that is faster usually but is slower
sometimes.

8. Fairness:
A good scheduler should make sure that each process gets its fair share of the CPU mean all
process should be given equal opportunity to execute. In particular do not allow a process to suffer
from starvation.

9. Priorities:
The Processes with higher priorities must be given preference for execution. For example job
submitted by system administrator should be given preference over less significant jobs of normal
user.

Process Scheduling Algorithm


1. Arrival Time:

The time at which the process enters into the ready queue is called the arrival time.
Unit # 2 : Process Management (20)

2. Burst Time:
The total amount of time required by the CPU to execute the whole process is called the Burst
Time. This does not include the waiting time.

3. Completion Time:
The Time at which the process enters into the completion state or the time at which the
process completes its execution, is called completion time.

4. Turnaround time:
The total amount of time spent by the process from its arrival to its completion, is called
Turnaround time. it is computed by subtracting the time, a process is terminated, from the time it is
entered into the system.

Turn Around Time = Completion Time - Arrival Time


Unit # 2 : Process Management (21)

5. Response Time:
The difference between the arrival time and the time at which the process first gets the CPU
is called Response Time.

6. Waiting Time
The Total amount of time for which the process waits for the CPU to be assigned is called
waiting time.
Waiting time= Finish Time – Burst time – arrival time

7. Throughput:
A measure of the work done by CPU is the number of processes being executed and
completed per unit time. This is called throughput.

Throughput = Sum of Burst Times of all processes / Total process

8. Gantt Chart:

Process Scheduling Algorithms:


 First Come First Serve (FCFS) -non-preemptive
Unit # 2 : Process Management (22)

 Shortest Job First (SJF) -non-preemptive


 Shortest Remaining Time Scheduling (SRT) -preemptive
 Priority Scheduling -preemptive or non-preemptive
 Round Robin Scheduling (RR) -preemptive

1) First Come First Serve Scheduling:

 FCFS scheduling algorithm simply schedules the jobs in order they arrived (according to their
arrival time).
 It is non-preemptive scheduling.
 The job which comes first in the ready queue will get the CPU first.
 The lesser the arrival time of the job, the sooner will the job gets the CPU.
 Although it is easy to implement, but it is poor in performance since the average waiting time is
higher as compare to other scheduling algorithms.

Advantages of FCFS
 It is very simple as First Come, First Serve.
 It is very easy to implement.

Disadvantages of FCFS
 The scheduling method is non-preemptive, the process will run to the completion. So a
process may have to wait for a long time.
 Due to the non-preemptive nature of the algorithm, the problem of starvation may occur.

Example
In the following schedule, there are 3 processes with process Name P1, P2and P3. P1 arrives
at time 0, P2 at time 1, and Process P3 arrives at time 2 in the ready queue. The processes and their
respective Arrival and Burst time are given in the following table.

Process name Arrival Time Burst Time


Process 1 0 24
Process 2 0 3
Process 3 0 3

Gantt Chart:

Waiti
ng Time = Finish Time – Burst Time – Arrival Time
Turnaround Time = Finish Time –Arrival Time
Throughput = Sum of Burst Times of all processes / Total process
Unit # 2 : Process Management (23)

Process Arrival Burst Finish Waiting Turnaround


Time Time Time Time Time
Process 1 0 24 24 0 24
Process 2 0 3 27 24 27
Process 3 0 3 30 27 30

Average Waiting Time : = ( 0 + 24 + 27 ) / 3 = 17


Average Turnaround Time: = ( 24 + 27+30 ) / 3 = 27
Average Throughput : = ( 24 + 3 + 3) / 3 = 10

2) Shortest Job First (SJF) Scheduling:

 Shortest Job First (SJF) is a non-preemptive algorithm


 It picks the job (process) in term of burst size that will take the shortest amount of time to
complete.
 In case of tie, first-come first-served scheduling can be used.
 Originally implemented in a batch-processing environment, in which estimated time supplied
with the batch job.

Advantages of SJF
 Maximum throughput
 Minimum average waiting and turnaround time

Disadvantages of SJF
 May suffer with the problem of starvation
 It is not implementable because the exact Burst time for a process can't be known in advance.

Process Name Arrival Time Burst Time


Process-1 0 7
Process-2 2 4
Process-3 4 2
Process-4 5 4

Gantt Chart:

Waiting Time:
Waiting time= Finish Time – Burst Time – Arrival Time

Process Arrival Time Burst Time Finish Time Waiting Time


Unit # 2 : Process Management (24)

Process-1 0 7 7 0
Process-2 2 4 13 7
Process-3 4 2 9 3
Process-4 5 4 17 8

Average Waiting Time = ( 0 + 7 + 3 + 8 ) / 4 = 4.5


3) Shortest Remaining Time (SRT) Scheduling:

 Shortest Remaining Time (SRT) is a preemptive version of Shortest Job First (SJF).
 It picks the job (process) in term of burst size that will take the shortest amount of time to
complete.
 Any time a new process enters the pool of process to be scheduled, the scheduler compares the
expected value for its remaining processing time with that of the process currently scheduled.
 If the new process’s burst time is less, the CPU suspended the currently executing process and
switches the control to the newly entered process.

Process Name Arrival Time Burst Time


Process-1 0 7
Process-2 2 4
Process-3 4 1
Process-4 5 4

Gantt Chart:

Waiting Time

Process Arrival Burst Finish Waiting


Time Time Time Time
Process-1 0 7 16 9
Process-2 2 4 7 1
Process-3 4 1 5 0
Process-4 5 4 11 2

Average Waiting Time = (9+1+0+2)/4 = 3

4) Priority Scheduling:
Unit # 2 : Process Management (25)

 In Priority scheduling, each process is assigned a priority value.


 Priority is generally an integer with some well-defined range e.g. 1 to 10.
 Scheduler picks the job that has the highest priority.
 Equal priority processes are scheduled in FCFS.
 Priority scheduling may be preemptive or non-preemptive.
 A preemptive priority scheduling will preempt the CPU, if the priority of the newly arriving
process in ready queue is higher than the priority of the currently running process.
 A non-preemptive priority scheduling will simply put the new arriving process at the tail of ready
queue.

Example:
a) In case of non-preemptive:
Assume that all processes arrived at time 0.

Process Name Arrival Time Burst Time Priority


Process-1 0 10 3
Process-2 0 1 1
Process-3 0 2 3
Process-4 0 1 4
Process-5 0 5 2

Gantt Chart:

Waiting Time:

Process Arrival Time Burst Time Finish Time Waiting Time


Process-1 0 10 16 6
Process-2 0 1 1 0
Process-3 0 2 18 16
Process-4 0 1 19 18
Process-5 0 5 6 1

Average waiting time = ( 6 + 0 + 16 + 18 + 1) / 5 = 8.2

b) In case of preemptive:

Process Name Arrival Time Burst Time Priority


Process-1 0 10 3
Unit # 2 : Process Management (26)

Process-2 2 1 1
Process-3 4 2 2
Process-4 6 1 4
Process-5 8 5 5

Gantt Chart:

Waiting Time:

Process Arrival Time Burst Time Finish Time Waiting Time


Process-1 0 10 13 3
Process-2 2 1 3 0
Process-3 4 2 6 0
Process-4 6 1 14 7
Process-5 8 5 19 6

Average waiting time = ( 3 + 0 + 0 + 7 + 6) / 5 = 3.2

Problem in Priority Scheduling:


One major problem with priority based scheduling is that it may not be fair. Some low
priority processes may not ever get the chance to execute because higher priority processes keep
stealing the CPU.

Solution:
One solution to this problem is to implement aging. The process of increasing the priority of
a process as it gets older is known as aging.

5) Round Robin Scheduling:

 Round Robin (RR) is a preemptive algorithm.


 It assigns a small amount of time to each process in which it executes.
 This time is called Time Quantum or Time Slice.
 The job is allocated to CPU for the time quantum.
 When the time quantum expires, the process is preempted from the CPU and replaced by the next
process in the circular queue.
Unit # 2 : Process Management (27)

Advantages:
 It can be actually implementable in the system because it is not depending on the burst time.
 It doesn't suffer from the problem of starvation or convoy effect.
 All the jobs get a fare allocation of CPU.

Disadvantages:
 The higher the time quantum, the higher the response time in the system.
 The lower the time quantum, the higher the context switching overhead in the system.
 Deciding a perfect time quantum is really a very difficult task in the system.

Example:
In the following schedule, there are 3 processes with process Name P1, P2and P3. P1
arrives at time 0, P2 at time 1, and Process P3 arrives at time 2 in the ready queue. The
processes and their respective Arrival and Burst time are given in the following table.

Assume that Quantum time is 4

Process name Arrival Time Burst Time


Process 1 0 24
Process 2 0 3
Process 3 0 3

Gantt Chart:

Waiting Time

Process Arrival Time Burst Time Finish Time Waiting Time


Process 1 0 24 30 6
Process 2 0 3 7 4
Process 3 0 3 10 7

Average Waiting Time: (6+4+7)/3 = 5.67


Unit # 2 : Process Management (28)

******************** Assignment-1 ********************


Process Arrival Time Burst Time
Process 1 0 3
Process 2 1 6
Process 3 4 4
Process 4 6 2

Draw Gantt’s Chart and Calculate:


Average Turnaround Time, Average Waiting Time and also throughput Using
Algorithms: FCFS , SJF & SRT

******************** Assignment-2 ********************


(2022)
Consider the following set of processes, with the length of the CPU burst given in
milliseconds and priority in numbers; lower the number higher the priority:

Process Burst Arrival Priority


Time Time
P1 8 1 1
P2 7 0 2
P3 6 3 0
P4 9 2 0

a) Draw a Gantt chart for, SRTF and Round Robin scheduling for time quantum = 4 milliseconds
b) Calculate average waiting time using priority scheduling with pre-emption and without pre-emption.
c) What is turnaround time for each process by using SJF?

******************** Assignment-3 ********************


(2023)
Process Arrival Time Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4

Using preemptive version of SJF, Draw Gantt Chart and Calculate average Waiting time

Q: – What are Process Supervisor Calls / System Calls? Describe different types of System Calls.
Unit # 2 : Process Management (29)

Ans: Supervisor calls are also known as system calls. A supervisor /system call is how a program
requests a service from an operating system’s kernel. It provides an interface between a running
program and operating system. These are set of function or methods used to request the operating
system to perform different operations in the computer system. For example, a process is created and
deleted through system calls. Similarly, the process can change its state from one to another and
many other I/O operations can be performed through system calls.
Most system calls are written in assembly language and are machine dependent. Several
higher level languages such as C also allow to writing system calls.
There are three general methods that are used to pass information (parameters) between a
running program and the operating system.

 One method is to store parameters in registers.


 Another is used to store parameters in a table in memory and pass the address of table.
 The third method is to push parameters on stack and allow operating system to pop the
parameters of the stack.

Main Types of System Calls


The main types of system calls are as follows:
o Process Control
o File Management
o Device Management
o Information Maintenance
o Communications

 Process Control :
These types of system calls are used to control the processes. Some examples are :

 End (terminates the process normally).


 Abort (terminates the process abnormally).
 Load and execute process.
 Create process and terminate process.
 Get or set process attributes etc.

In Unix operating system, the most important system calls used to control the processes are as
follows:

o fork( ) : This system call is used to create new process. After executing fork( ) system
call, the parent process continues running, in parallel with the child. The
parent may create many children. Each child may also create its own children
through fork( ) system call. So a tree like structure of processes is created.
o wait( ): The parent may issue this system call to move itself into waiting state, while
the child runs.
Unit # 2 : Process Management (30)

o exit( ): This system call is used to terminate the execution of the process.
o abort( ): This system call allows one process to terminate another, but this facility can
Only be used by parent process.

 File Management:
These types of system calls are used to manage files.
Some examples are Create file, delete file, open, close, read, write etc.

 Device Management:
These types of system calls are used to manage devices.
Some examples are Request device, release device, read, write, etc.

 Information Maintenance:
These types of system calls are used to maintain information.
Some examples are Get time or date, set time or date, get system data, set system data etc.

 Communications:
These types of system calls are used to for communication.
Some examples are create, delete communication connection, send, receive messages etc.

Q: – Describe different types of operations that can be performed on a process using System
Calls.

Ans: Operations on Processes:


The operating system must provide mechanism for creating and terminating processes
dynamically. A process is created through supervisor call. When a process is created the
operating system must create a PCB for that process.

 Process Creation
When a new process is to be created, the operating system builds its data structure (PCB),
which is used to manage the process. It allocates address spaces in memory for the process.

Parent process creates children processes. The children processes can also create other
processes forming a tree of processes. A process may create zero or more new child processes.
Process creation may be limited by the amount of resources that a parent process has. If a
parent process creates a child process, the child process may create child processes of its own. It
results in a tree of processes. When a child process is created, it may be able to obtain resources
directly from the parent. It may only be able to obtain a subset of the parent's resources or it must
acquire its resources. It is usually a good idea to limit the resources of child process as a single
user process could create hundreds of child processes. Each might be able to acquire resources of
their own, leaving no resources for other process and effectively giving control of the machine to
a single user process.
Unit # 2 : Process Management (31)

When a process creates a new process, the parent may continue to execute concurrently with
its children or it must wait until some or all its children have terminated execution.

In terms of address space, the child may be an exact duplicate of parent. This would allow the
child and parent to communicate very easily as they share the same address space. It should be
possible to load a new program into the address space of the child. It is also possible to create an
entirely new process and place a new program into it. This makes it more difficult for the child
and parent to communicate since they have nothing in common.

 Process Termination
A process normally terminates when it has finished executing its last statement. It typically
tells the operating system by issuing some form of the exit( ) system call. At this point, the
process may output some data to its parent if it is a child process. Eventually the process has all
its resources removed from it and is no longer part of the job pool. A child process may be
terminated by its parent using the abort( ) system call. This may occur because the child has
asked for too many resources, the child is no longer wanted or the parent is terminating. The
operating system may or may not allow a child process to continue executing after its parent
terminates. In some cases, the child process should not continue. In other cases, a child process
may continue after the parent has, finished.

Important Questions

1. Differentiate between swapper and dispatcher.

2. What is the difference between process and threads? Explain different states of process and
their functions. (2023)
Unit # 2 : Process Management (32)

3. What is Process? Explain different states of process and transition with diagram.
4. Draw and explain process state transition diagram.
5. What are secluding criteria you would select to optimize the system
6. Explain Context Switching and PCB (Process Control Block).
7. Consider the following set of processes, with the length of the CPU burst given in
milliseconds and priority in numbers; lower the number higher the priority: (2022)

Process Burst Arrival Priority


Time Time
P1 8 1 1
P2 7 0 2
P3 6 3 0
P4 9 2 0

a) Draw a Gantt chart for, SRTF and Round Robin scheduling for time quantum = 4 milliseconds.
b) Calculate average waiting time using priority scheduling with pre-emption and without pre-
emption.
c) What is turnaround time for each process by using SJF?

You might also like