Process Management in Operating Systems
Process Management in Operating Systems
of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
MODULE – II
Processes Concept
A process is a program under execution.
Its current activity is indicated by PC(Program Counter) and CPU registers.
The stack is used to store local variables, function parameters, function return
values, returnaddress etc.
The heap is used for dynamic memory allocation.
The data section stores global and static variables.
The text section comprises the compiled program code.
Note that, there is a free space between the stack and the heap. When the stack
is full, itgrows downwards and when the heap is full, it grows upwards.
Process States
A Process has 5 states. Each process may be in one of the following states –
For each process there is a Process Control Block (PCB), which stores the process-
specificinformation as shown below –
Process State – The state of the process may be new, ready, running, waiting, and so on.
Program counter – The counter indicates the address of the next instruction to be executed for
this process.
CPU registers - The registers vary in number and type, depending on the computer architecture.
They include accumulators, index registers, stack pointers, and general-purpose registers. Along
with the program counter, this state information must be saved when an interrupt occurs, to allow
the process to becontinued correctly afterward.
CPU scheduling information- This information includes a process priority, pointers to
schedulingqueues, and any other scheduling parameters.
Memory-management information – This include information such as the value of the base
and limit registers, the page tables, or the segment tables.
Accounting information – This information includes the amount of CPU and real time used,
time limits, account numbers, job or process numbers, and so on.
I/O status information – This information includes the list of I/O devices allocated to the
process, a listof open files, and so on.
The PCB simply serves as the repository for any information that may vary from process to
process.
Process Scheduling
Process Scheduler selects an available process for program execution on the CPU.
In a multiprocessor system - one process will be under execution and the rest of the
processes have to wait until the CPU is free and can be rescheduled.
The main objective of process scheduling is to keep the CPU busy at all times.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Scheduling Queues
All processes admitted to the system are stored in the job queue.
Processes in main memory and ready to execute are placed in the ready queue.
Processes waiting for a device to become available are placed in device
queues. There isgenerally a separate device queue for each device.
These queues are generally stored as a linked list of PCBs. A queue header will contain two
pointers - the head pointer pointing to the first PCB and the tail pointer pointing to the last
PCB in the list. Each PCB has a pointer field that points to the next process in the queue.
When a process is allocated to the CPU, it executes for a while and eventually quits,
interrupted, or waits for the completion of an I/O request. Since there are many processes in
the system, the disk may be busy with the I/O request of some other process. The process
therefore may have to wait for the disk in the device queue.
A new process is initially put in the ready queue. It waits in the ready queue until it is
selected for execution and is given the CPU. Once the process is allocated the CPU and is
executing, one of several events could occur:
The process could issue an I/O request, and then be placed in an I/O queue.
The process could create a new subprocess and wait for its termination.
The process could be removed forcibly from the CPU, as a result of an interrupt,
and be put backin the ready queue.
In the first two cases, the process eventually switches from the waiting state to the ready
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
state, and is then put back in the ready queue. A process continues this cycle until it
terminates, at which time it is removedfrom all queues.
Schedulers
The short-term scheduler, or CPU Scheduler – selects job from memory and
assigns the CPUto it. It must select the new process for CPU frequently.
An efficient scheduling system will select a good mix of CPU-bound processes and I/O
bound processes.
If the scheduler selects more I/O bound process, then I/O queue will be
full and readyqueue will be empty.
If the scheduler selects more CPU bound process, then ready queue will be
full and I/Oqueue will be empty.
Time sharing systems employ a medium-term scheduler. It swaps out the process from
ready queue and swap in the process to ready queue. When system loads get high, this
scheduler will swap one or more processes out of the ready queue for a few seconds, in
order to allow smaller faster jobs to finish up quickly and clear the system.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Advantages of medium-term scheduler –
To remove process from memory and thus reduce the degree of
multiprogramming(number of processes in memory).
To make a proper mix of processes(CPU bound and I/O bound )
Context Switch
Context switch time is an overhead, as the system does not do useful work while switching.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Operations on Processes
Process Creation
A process may create several new processes. The creating process is called a parent
process, and the new processes are called the children of that process. Each of these new
processes may in turn create other processes. Every process has a unique process ID.
On typical Solaris systems, the process at the top of the tree is the ‘sched’ process
with PID of 0. The ‘sched’ process creates several children processes – init, pageout and
fsflush. Pageout and fsflush are responsible for managing memory and file systems. The init
process with a PID of 1, serves as a parent process for all user processes.
A process will need certain resources (CPU time, memory, files, I/O devices) to
accomplish its [Link] a process creates a subprocess, the subprocess may be able to
obtain its resources in two ways :
directly from the operating system
Subprocess may take the resources of the
parent process. The resource can be
taken from parent in two ways –
o The parent may have to partition its resources among its children
o Share the resources among several children.
There are two options for the parent process after creating the child:
Wait for the child process to terminate and then continue execution. The parent makes
a wait( ) system call.
Run concurrently with the child, continuing to execute without waiting.
Two possibilities for the address space of the child relative to the parent:
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
The child may be an exact duplicate of the parent, sharing the same program and
data segments in memory. Each will have their own PCB, including program
counter, registers, and PID. This is the behaviour of the fork system call in UNIX.
The child process may have a new program loaded into its address space, with all
new code and data segments. This is the behaviour of the spawn system calls in
Windows.
In UNIX OS, a child process can be created by fork() system call. The fork system call, if
successful, returns the PID of the child process to its parents and returns a zero to the child
process. If failure, it returns -1 to the parent. Process IDs of current process or its direct
parent can be accessed using the getpid( ) and getppid( ) system calls respectively.
The parent waits for the child process to complete with the wait() system call.
When the childprocess completes, the parent process resumes and completes its execution.
In windows the child process is created using the function createprocess( ). The
createprocess( ) returns 1, if the child is created and returns 0, if the child is not created.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Process Termination
A process terminates when it finishes executing its last statement and asks the operating
system to delete it, by using the exit( ) system call. All of the resources assigned to the
process like memory, open files, and I/O buffers, are deallocated by the operating system.
A process can cause the termination of another process by using appropriate
system call. Theparent process can terminate its child processes by knowing of the PID of
the child.
A parent may terminate the execution of children for a variety of reasons, such as:
The child has exceeded its usage of the resources, it has been allocated.
The task assigned to the child is no longer required.
The parent is exiting, and the operating system terminates all the children.
This is calledcascading termination.
Note : Processes which are trying to terminate but which cannot because their parent is not
waiting for them are termed zombies. These are eventually inherited by init as orphans and
killed off. (Modern UNIX shells do not produce as many orphans and zombies as older
systems used to. )
Interprocess Communication
Processes executing may be either co-operative or independent processes.
Independent Processes – processes that cannot affect other processes or be
affected by otherprocesses executing in the system.
Cooperating Processes – processes that can affect other processes or be
affected by otherprocesses executing in the system.
Co-operation among processes are allowed for following reasons –
Information Sharing - There may be several processes which need to access the
same file. So the information must be accessible at the same time to all users.
Computation speedup - Often a solution to a problem can be solved faster if the
problem can be broken down into sub-tasks, which are solved simultaneously (
particularly when multiple processors are involved. )
Modularity - A system can be divided into cooperating modules and executed by
sending information among one another.
Convenience - Even a single user can work on multiple task by information sharing.
3. System call is used only to create shared System call is used during every read
memory and write operation.
4. Message is sent faster, as there are no Message is communicated slowly.
system calls
Shared Memory is faster once it is set up, because no system calls are required and
access occurs at normal memory speeds. Shared memory is generally preferable
when large amounts of information must be shared quickly on the same computer.
Message Passing requires system calls for every
message transfer, and is therefore slower, but it is
simpler to set up and works well across multiple
computers. Message passing is generally preferable
when the amount and/or frequency of data transfers is
small.
Shared-Memory Systems
The process should take care that the two processes will not write the data to the
shared memoryat the same time.
This is a classic example, in which one process is producing data and another process is
consuming the data.
The data is passed via an intermediary buffer (shared memory). The producer puts the
data to the buffer and the consumer takes out the data from the buffer. A producer can
produce one item while the consumer is consuming another item. The producer and
consumer must be synchronized, so that the consumer does not try to consume an item that
has not yet been produced. In this situation, the consumer must wait until an item is
produced.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
There are two types of buffers into which information can be put –
Unbounded buffer
Bounded buffer
With Unbounded buffer, there is no limit on the size of the buffer, and so on the data
produced byproducer. But the consumer may have to wait for new items.
With bounded-buffer – As the buffer size is fixed. The producer has to wait if the buffer is full
and theconsumer has to wait if the buffer is empty.
This example uses shared memory as a circular queue. The in and out are two pointers to
the array. Notein the code below that only the producer changes "in", and only the consumer
changes "out".
First the following data is set up in the shared memory area:
} item;
item buffer[ BUFFER_SIZE ];
int in = 0;
int out = 0;
Message-Passing Systems
A mechanism to allow process communication without sharing
addressspace. It is used in distributed systems.
Message passing systems uses system calls for "send message" and "receive message".
A communication link must be established between the cooperating processes before
messages canbe sent.
There are three methods of creating the link between the sender and the receiver-
o Direct or indirect communication ( naming )
o Synchronous or asynchronous communication (Synchronization)
o Automatic or explicit buffering.
a) Naming
The processes that wants to communicate should have a way to refer eachother. (
using someidentity)
Direct communication the sender and receiver must explicitly know eachothers name.
The syntax forsend() and receive() functions are as follows-
A mail box can be owned by the operating system. It must take steps to –
create a new mailbox
send and receive messages from mailbox
delete mailboxes.
b) Synchronization
The send and receive messages can be implemented as either blocking or non-blocking.
c) Buffering
when messages are passed, a temporary queue is created. Such queue can be of three
capacities:
Zero capacity – The buffer size is zero (buffer does not exist). Messages are not
stored in thequeue. The senders must block until receivers accept the messages.
Bounded capacity- The queue is of fixed size(n). Senders must block if the queue
is full. Aftersending ‘n’ bytes the sender is blocked.
Unbounded capacity - The queue is of infinite capacity. The sender never blocks.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Many modern operating systems have extended the process concept to allow a
process to have multiple threads of execution and thus to perform more than
one task at a time.
A thread is a basic unit of CPU utilization; it comprises a thread ID, a program
counter, a register set, and a stack. It shares with other threads belonging to the
same process its code section, data section, and other operating-system resources,
such as open files and signals. A traditional (or heavy weight) process has a single
thread of control. If a process has multiple threads of control, it can perform more
than one task at a time.
Multithreading Models
Support for threads may be provided either at the user level, for user threads or
by the kernel, for kernel threads. User threads are supported above the kernel and
are managed without kernel support, whereas kernel threads are supported and
managed directly by the operating system. Ultimately, a relationship must exist
between user threads and kernel threads.
1. Many to One Model
Threading Issues
1. The fork() and exec() System Calls
□ If one thread in a program calls fork(), does the new process duplicate all
threads, or is the new process single-threaded? Some UNIX systems have
chosen to have two versions of fork(), one that duplicates all threads and
another that duplicates only the thread that invoked the fork() system call.
□ If a thread invokes the exec() system call, the program specified in the
parameter to exec () will replace the entire process-including all threads.
2. Cancellation
□ Thread cancellation is the task of terminating a thread before it has
completed. For example, if multiple threads are concurrently searching
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
through a database and one thread returns the result, the remaining threads
might be canceled.
□ A thread that is to be canceled is often referred to as the target thread.
□ Cancellation of a target thread may occur in two different scenarios:
o Asynchronous cancellation. One thread immediately
terminates the targetthread.
o Deferred cancellation. The target thread periodically checks
whether it should terminate, allowing it an opportunity to
terminate itself in an orderly fashion.
□ The difficulty with cancellation occurs in situations where resources have
been allocated to a canceled thread or where a thread is canceled while in
the midst of updating data it is sharing with other threads.
3. Signal Handling
□ A signal is used in UNIX systems to notify a process that a particular event has
occurred.
All signals, whether synchronous or asynchronous, follow the same pattern:
o A signal is generated by the occurrence of a particular event.
o A generated signal is delivered to a process.
o Once delivered, the signal must be handled.
□ Examples of synchronous signals include illegal memory access and
division by 0. If a running program performs either of these actions, a
signal is generated.
□ Every signal has a default signal handler that is run by the kernel when
handling that signal. This default action can be overridden by a user
defined signal handler that is called to handle the signal.
□ Handling signals in single-threaded programs is straightforward: signals
are always delivered to a process. However, delivering signals is more
complicated in multithreaded programs, where a process may have several
threads. Where, then, should a signal be delivered?
□ In general the following options exist:
o Deliver the signal to the thread to which the signal applies.
o Deliver the signal to every thread in the process.
o Deliver the signal to certain threads in the process.
o Assign a specific thread to receive all signals for the process.
4. Thread Pools
□ The first issue concerns the amount of time required to create the thread
prior to servicing the request, together with the fact that this thread will be
discarded once it has completed its work.
□ The second issue is more troublesome: if we allow all concurrent requests
to be serviced in a new thread, we have not placed a bound on the number
of threads concurrently active in the system. Unlimited threads could
exhaust system resources, such as CPU time or memory. One solution to
this problem is to use a thread pool.
□ The general idea behind a thread pool is to create a number of threads at
process startup and place them into a pool, where they sit and wait for
work.
□ Thread pools offer these benefits:
o Servicing a request with an existing thread is usually faster than
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
waiting to create a thread.
o A thread pool limits the number of threads that exist at any one
point. This is particularly important on systems that cannot
support a large number of concurrent threads.
5. Thread-Specific Data
□ Threads belonging to a process share the data of the process. Indeed, this
sharing of dataprovides one of the benefits of multithreaded programming.
□ However, in some circumstances, each thread might need its own copy of certain
data.
We will call such data thread specific data.
□ For example, in a transaction-processing system, we might service each transaction
in a
separate thread. Furthermore, each transaction might be assigned a unique
identifier. Toassociate each thread with its unique identifier, we could use
thread-specific data.
6. Scheduler Activations
A final issue to be considered with multithreaded programs concerns
communication between the kernel and the thread library, which may be
required by the many-to-many and two-level models.
Such coordination allows the number of kernel threads to be dynamically
adjusted to help ensure the best performance.
This can be achieved with the help of scheduler
activations. Many systems implementing either the many-to-many or two-level
model place an intermediate data structure between the user and kernel threads.
This data structure—typically known as a lightweight process, or LWP.
The kernel provides an application with a set of virtual processors (LWPs), and
the applicationcan schedule user threads onto an available virtual processor.
Furthermore, the kernel must inform an application about certain events.
This procedure isknown as an upcall.
Upcalls are handled by the thread library with an upcall handler, and upcall
handlers must runon a virtual processor.
One event that triggers an upcall occurs when an application thread is about to block.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Advantages of Thread
Threads minimize the context switching time.
Use of threads provides concurrency within a process.
Efficient communication.
It is more economical to create and context switch threads.
Threads allow utilization of multiprocessor architectures to a greater scale and
efficiency.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
2.3.1CPU Scheduler
Whenever the CPU becomes idle, the operating system must select one of the
processes in theready queue to be executed.
The selection process is carried out by the short-term scheduler (or CPU scheduler).
The scheduler selects a process from the processes in memory that are ready
to execute andallocates the CPU to that process.
2.3.2Preemptive Scheduling
□ CPU-scheduling decisions may take place under the following four circumstances:
1. When a process switches from the running state to the waiting
state (for example, as the result of an I/0 request or an invocation
of wait for the termination of oneof the child processes)
2. When a process switches from the running state to the ready
state (for example,when an interrupt occurs)
3. When a process switches from the waiting state to the ready state (for
example, at completion of I/0)
4. When a process terminates
5.1.2 Dispatcher
□ The dispatcher is the module that gives control of the CPU to the process
selected by theshort-term scheduler. This function involves the following:
o Switching context
o Switching to user mode
o Jumping to the proper location in the user program to restart that program.
□ The dispatcher should be as fast as possible, since it is invoked during
every process switch. The time it takes for the dispatcher to stop one
process and start another running isknown as the dispatch latency.
With this scheme, the process that requests the CPU first is allocated the CPU first.
The implementation of the FCFS policy is easily managed with a 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.
The runningprocess is then removed from the queue.
On the negative side, the average waiting time under the FCFS policy is often quite
long.
FCFS scheduling algorithm is non-preemptive. Once the CPU has been allocated to a
process, that process keeps the CPU until it releases the CPU, either by terminating or
by requesting I/0.
The FCFS algorithm is thus particularly troublesome for time-sharing systems,
where it is important that each user get a share of the CPU at regular intervals. It
would be disastrousto allow one process to keep the CPU for an extended period.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
Example:
Process Burst Time
P1 24
P2 3
P3 3
If the processes arrive in the order P1, P2, P3, and are served in FCFS
order, we get theresult shown in the following Gantt chart.
P1 P2 P3
0 24 27 30
Process Waiting Time Turnaround Time =
(Waiting Time + Burst Time)
P1 0 0 + 24 = 24
P2 24 24+ 3 = 27
P3 27 27 + 3 = 30
CPU
Burst Completion Turnaround
Time Wait Time Response
Process Time Time (TAT) (TAT (WT) Time
(CT) (CT – AT) – BT) (RT)
(BT)
P1 24 24 24 0 0
P2 3 27 27 24 24
P3 3 30 30 27 27
Average Waiting Time = (0 + 24 + 27) / 3 = 17 milliseconds.
Average Turnaround Time = (24 + 27 + 30) / 3 = 27 milliseconds
If the processes arrive in the order P2, P3 , P1, however, the results will
be as shown inthe following Gantt chart:
P2 P3 P1
0 3 6 30
Process Waiting Time Turnaround Time =
(Waiting Time + Burst Time)
P1 6 6 + 24 = 30
P2 0 0+3=3
P3 3 3+3=6
OR
CPU
Burst Completion Turnaround
Time Wait Time Response
Process Time Time (TAT) (WT) Time
(BT)
(CT) (CT – AT) (TAT – BT) (RT)
P1 24 30 30 6 6
P2 3 3 3 0 0
P3 3 6 6 3 3
Example:
P4 P1 P3 P2
0 3 9 16 24
Non-preemptive SJF scheduling would result in an average waiting time of 7.75 milliseconds as
shown below:
Gantt Chart
P1 P2 P4 P3
0 8 12 17 26
CPU
Arrival Burst Completion Turnaround
Time Wait Time Response
Process Time Time Time (TAT) (TAT (WT) Time
(AT) (CT) (CT – AT) – BT) (RT)
(BT)
P1 0 8 8 8 0 0
P2 1 4 12 11 7 8
P3 2 9 26 24 15 17
P4 3 5 17 14 9 12
Thus average waiting time = (0 + 7 + 15 + 9)/4 = 7.75 ms.
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
4. Priority Scheduling
The SJF algorithm is a special case of the general priority scheduling algorithm. A
priority is associated with each process, and the CPU is allocated to the process
with the highest priority. Equal-priority processes are scheduled in FCFS order.
As an example, consider the following set of processes, assumed to have arrived at
time 0 in the order P1, P2, P3, P4, P5with the length of the CPU burst given in
milliseconds:
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
P2 P5 P1 P3 P4
0 1 6 16 18 19
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
OR
CPU
Burst Completion Turnaround
Time Wait Time Response
Process Time Time (TAT) (TAT (WT) Time
(CT) (CT – AT) – BT) (RT)
(BT)
P1 24 30 30 6 0
P2 3 7 7 4 4
P3 3 10 10 7 7
P1 waits for 6 milliseconds (10- 4), P2 waits for 4 milliseconds, and P3 waits
for 7milliseconds.
The average waiting time is (6+4+7) = 17/3 = 5.66 milliseconds.
The average turnaround time is now (30 + 7 + 10)/3 = 15.66 milliseconds.
If a process's CPU burst exceeds 1 time quantum, that process is preempted and is
putback in the ready queue. The RR scheduling algorithm is thus preemptive.
The performance of the RR algorithm depends heavily on the size of the time
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
quantum.
At one extreme, if the time quantum is extremely large, the RR policy is the same
as theFCFS policy.
In contrast, if the time quantum is extremely small (say, 1 millisecond), the RR
approach is called processor sharing and (in theory) creates the appearance that
each of n processes has its own processor running at 1 / n the speed of the real
processor.
Problem 1: Consider the following processes with the CPU burst time given in milliseconds
Calculate average turnaround time and average waiting time for the following algorithms
drawing Gantt chart.
i) FCFS
ii) Preemptive SJF
iii) Round Robin(quantum=1 unit)
Sol: i) FCFS
Gantt Chart
P1 P2 P3 P4
0 8 12 21 26
Process Arrival Burst Completion Turnaround Waiting Time
Time Time Time (CT) Time (TAT) (TAT – BT)
(AT) (BT) (CT – AT)
P1 0 8 8 8 0
P2 1 4 12 11 7
P3 2 9 21 19 10
P4 3 5 26 23 18
P1 P2 P4 P1 P3
0 1 5 10 17 26
P3 P4 P1 P3 P1 P3 P3 P3
Gantt Chart
P1 P2 P1 P3 P2 P4 P1 P3 P2 P4 P1 P3 P2 P4 P1 P3 P4 P1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
P3 P4 P1 P3 P1 P3 P3 P3
19 20 21 22 23 24 25 26
Problem 2: Consider the following processes with the CPU burst time given in milliseconds
Assuming Preemptive mode and criteria as Priority based, compute the Completion time of each
process using Gantt chart. Also calculate CPU idle time and CPU usage time in percentage.
Sol:
Gantt Chart
|==P3 I/O === | |=====P4 I/O ====|
P1 P2 P3 P3 P2 P1 P1 P3 P1 P2 P4 P4 P2 P4
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
CPU Idle Time = 4/18 = 22.22% CPU Usage Time = 14/18 = 77.78
Subject Module 2 Prepared by: Dept. of ISE, DBIT
Operating Systems Process, Thread and Process
(BCS303) Scheduling
The scheduler first executes all processes in queue 0. Only when queue 0
is empty will it execute processes in queue 1. Similarly, processes in queue
2 will only be executed if queues 0 and 1 are empty. A process that arrives
for queue 1 will preempt a process in queue 2. A process in queue 1 will in
turn be preempted by a process arriving for queue 0.
A process entering the ready queue is put in queue 0. A process in queue 0
is given a time quantum of 8 milliseconds. If it does not finish within this
time, it is moved to the tail of queue 1. If queue 0 is empty, the process at
the head of queue 1 is given a quantum of 16 milliseconds. If it does not
complete, it is preempted and is put into queue 2. Processes in queue 2 are
run on an FCFS basis but are run only when queues 0 and 1 are empty.
Question Bank
1. With neat flow diagram explain the different stages of a Process.
2. Describe message passing model and Shared memory model of communication between
processes
3. Discuss the reasons for providing an environment that allows process
Cooperation.
4. Describe the differences among short-term, medium-term, and longterm
scheduling.
5. What is multithreading? What are the benefits of multithreaded programming?
(June 10 / Dec 11)
6. Write a note on multithreaded models. (June 09 / Dec 09)
7. Consider 4 jobs with (arrival time, burst time) as (0, 5) (0.2, 2) (0.6, 8) (1.2, 4).
Find the average turnaround time and waiting time for the jobs using FCFS, SJF
and RR(q=1) scheduling algorithms. (June11)
8. Consider the following set of processes. (June10)
Process Arrival Time Burst Time
P1 0 1
P2 1 9
P3 2 1
P4 3 9
a) Draw Gantt charts showing the execution of these processes using FCFS,
preemptive SJF, non-Pre-emptive SJF and RR (Quantum 1) scheduling
schemes.
b) Compute the turnaround time and waiting time for each process for each
of the schemesabove.
c) Compute the average turnaround time and average waiting time in each
scheme and thusfind the best scheme in this particular case.
9. Why thread is called LWP? Describe any one threading model. (Dec 08)
10. Suppose the following jobs arrive for processing at the times indicated. Each
job will run the listed amount of time.
Job 1 2 3
Arrival Time 0.0 0.4 1.0
Burst Time 8 4 1
a) Give Gantt chart illustrating the execution of these jobs using the non-
preemptive FCFS and SJF scheduling algorithms..
b) What is turnaround time and waiting time of each job for the above algorithms?
c) Compute average turnaround time if CPU is left idle for 1 unit and then SJF is
used.(Job1and Job2 will wait during this time) Dec.09)
11. Consider the following set of processor with a length of CPU burst time given in
milliseconds.