os unit 2 new questions
os unit 2 new questions
1. Define Process?[R]
A Process can be thought of as a program in execution. A process will need certain resources such as CPU time,
memory, files & I/O devices to accomplish its task.
Draw & briefly explain the process states?[U] or Name and draw five different process states with proper
definition. (NOV/DEC 2017)
Process state
Process number
Program counter
CPU registers
Memory limits
Accounting information
Responsiveness
Resource sharing
Economy scalability
CPU utilization
Throughput
Turnaround time
Waiting time
Response time
9.Write down the definition of TestAndSet() Instruction.[R] boolean
TestAndSet (boolean &target)
{
boolean rv = *target;
*target = true; return
rv;
}
10. Define busy waiting and spinlock. [R]
Busy waiting:-
When a process is in its critical section, any other process that tries to enter its critical section must loop
continuously in the entry code. This is called as busy waiting.
Spinlock:-
Busy waiting waster CPU cycles that some other process might be able to use productively.This type
of semaphore is also called a spinlock because the process―spin‖ while waiting for the lock.
11. What is mean by monitors?[R]
A high level synchronization construct. A monitor type is an ADT which presents set of programmer define
operations that are provided mutual exclusion within the monitor.
12. What are the characterizations of deadlock?[R]
1. Mutual exclusion: only one process at a time can use a resource.
2. Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by
other processes.
3. No preemption: a resource can be released only voluntarily by the process holding it, after that process
has completed its task.
4. Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a
resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a
resource that is held by Pn, and P0 is waiting for a resource that is held by P0.Deadlock can arise if four
conditions hold simultaneously.
13. Differentiate a Thread form a Process. (NOV/DEC 2012)[An] Threads
14. What are the difference b/w user level threads and kernel level threads? (MAY/JUNE 2012) (MAY/ JUNE
2016) (NOV/DEC 2015)[An]
User threads
User threads are supported above the kernel and are implemented by a thread library at the user level. Thread
creation & scheduling are done in the user space, without kernel intervention. Therefore they are fast to
create and manage blocking system call will cause the entire process to block
Kernel threads
Kernel threads are supported directly by the operating system .Thread creation, scheduling and management
are done by the operating system. Therefore they are slower to create & manage compared to user threads. If the
thread performs a blocking system call, the kernel can schedule another thread in the application for execution
15. What is the use of fork and exec system calls?[R]
Fork is a system call by which a new process is created. Exec is also a system call, which is used after a fork
by one of the two processes to place the process memory space with a new program.
16. Define thread cancellation & target thread.[R]
The thread cancellation is the task of terminating a thread before it has completed. A thread that is to be
cancelled is often referred to as the target thread. For example, if multiple threads are concurrently searching
through a database and one thread returns the result, the remaining threads might be cancelled.
17. What are the different ways in which a thread can be cancelled?[An]
Cancellation of a target thread may occur in two different scenarios:
• Asynchronous cancellation: One thread immediately terminates the target thread is called asynchronous
cancellation.
• Deferred cancellation: The target thread can periodically check if it should terminate, allowing the
target thread an opportunity to terminate itself in an orderly fashion.
18. Define PThreads[R]
PThreads refers to the POSIX standard defining an API for thread creation and synchronization. This is a
specification for thread behavior, not an implementation.
19. What is critical section problem?[R]
Consider a system consists of 'n' processes. Each process has segment of code called a critical section, in
which the process may be changing common variables, updating a table, writing a file. When one process is
executing in its critical section, no other process can be allowed to execute in its critical section.
21. What are the requirements that a solution to the critical section problem must satisfy?[R]
The three requirements are
Mutual exclusion
Progress & Bounded waiting
22. Define mutual exclusion. (MAY/JUNE 2013)[R]
Mutual exclusion refers to the requirement of ensuring that no two process or threads are in their critical
section at the same time.
i.e. If process Pi is executing in its critical section, then no other processes can be executing in their critical
sections.
23. Define entry section and exit section.[R]
The critical section problem is to design a protocol that the processes can use to cooperate. Each process must
request permission to enter its critical section.
Entry Section: The section of the code implementing this request is the entry section.
Exit Section: The section of the code following the critical section is an exit section.
The general structure:
do {
entry section
critical section
exit section
remainder section
} while(1);
24. Give two hardware instructions and their definitions which can be used for implementing
mutual exclusion.[An]
TestAndSet
boolean TestAndSet (boolean &target)
{
boolean rv = target; target =
true;
return rv;
}
Swap
void Swap (boolean &a, boolean &b)
{
boolean temp = a;
a = b;
b = temp;
}
25. What is semaphore? Mention its importance in operating system. (APRIL/MAY 2010, NOV/DEC
2012)[R]
A semaphore 'S' is a synchronization tool which is an integer value that, apart from initialization, is
accessed only through two standard atomic operations; wait and signal. Semaphores can be used to deal with
the n-process critical section problem. It can be also used to solve various Synchronization problems.
26. How the mutual exclusion may be violated if the signal and wait operations are not executed
automatically (MAY/JUNE 2014)[An]
A wait operation atomically decrements the value associated with a semaphore. If two wait operations are
executed on a semaphore when its value is1, if the two operations are not performed atomically, then it is
possible that both operations might proceed to decrement the semaphore value, thereby violating mutual
exclusion
27. Define CPU scheduling.[R]
CPU scheduling is the process of switching the CPU among various processes. CPU scheduling is the basis
of multi programmed operating systems. By switching the CPU among processes, the operating system can make
the computer more productive.
28. What is preemptive and non-preemptive scheduling? [An] (NOV/DEC 2008
,APRIL/MAY2010, MAY /JUNE 2012)
Under non preemptive scheduling once the CPU has been allocated to a process, the process keeps the
CPU until it releases the CPU either by terminating or switching to the waiting state.
Preemptive scheduling can preempt a process which is utilizing the CPU in between its execution and
give the CPU to another process.
29. What is a Dispatcher?[R]
The dispatcher is the module that gives control of the CPU to the process selected by the short-term
scheduler. This function involves:
Switching context.
Jumping to the proper location in the user program to restart that program.
30. Define the term „dispatch latency‟ (APR/MAY 2015)[R]
The time taken by the dispatcher to stop one process and start another running is known as dispatch
latency.
31. Define throughput?[R]
Throughput in CPU scheduling is the number of processes that are completed per unit time. For long
processes, this rate may be one process per hour; for short transactions, throughput might be 10 processes per
second.
32. What is turnaround time? (NOV/DEC 2013)[R]
Turnaround time is the interval from the time of submission to the time of completion of a process.
It is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the
CPU, and doing I/O.
33. Define race condition.[R]
When several process access and manipulate same data concurrently, then the outcome of the execution depends
on particular order in which the access takes place is called race condition. To avoid race condition, only one
process at a time can manipulate the shared variable.
34. Write the four situations under which CPU scheduling decisions take place (MAY/JUNE 2014)
[R]
CPU scheduling decisions take place under one of four conditions:
When a process switches from the running state to the waiting state, such as for an I/O request or
invocation of the wait ( ) system call.
When a process switches from the running state to the ready state, for example in response to an
interrupt.
When a process switches from the waiting state to the ready state, say at completion of I/O or
a return from wait ( ).
Request: If the request cannot be granted immediately, then the requesting process must wait
until it can acquire the resource.
47. Differentiate single threaded and multi-threaded processes. (APR/MAY 2017) [An]
S. Multithreaded Programming Single Threaded Programming
No.
2 Multi-threaded model doesn‘t use event Single threaded model uses a process
loop with polling event loop with polling
3 CPU time is never wasted. CPU time is wasted.
6 When one thread is paused due to some When one thread is paused, the system
reason, other threads run as normal. waits until this thread is resumed.
There‘s less pressure on the system to act on the information or immediately respond in some way.
Also, one system being down does not impact the other system. For example, emails –thousands of
emails can be sent without having to revert back..
Benefits of Asynchronous communication:
Since a process does not block, it can do some computation while the message is in transit.
In the case of receive, this means a process can express its interest in receving messages on
multiple ports simultaneously.
50. Give a programming example in which multithreading does not provide better performance than
single-threaded solutions. (APR/MAY 2018)
Multi-threading does not perform well for any sequential program. For example; program to calculate an
individual tax return. Another example where multithreading does not work good would be shell program like
―Korn‖ shell.
51. Give the queuing diagram representation of process scheduling. (APR/MAY 2019)
52. List out the benefits and challenge of thread handling. (APR/MAY 2019)
Benefits
Responsiveness.
Resource sharing
Economy
Scalability.
Challenges
Dividing activities
Balance
Data splitting
Data dependency
P1 0 8
P2 1 4
P3 2 9
P4 3 5
2) Discuss how scheduling algorithms are selected for a system. What are the criteria considered?
Explain the different evaluation Methods.[An] (MAY/JUNE 2014)
3) Write in detail about several CPU scheduling algorithms. [An] (APRIL/MAY2011)
4) What is critical section? Specify the requirements for a solution to critical section problem.
[An] (NOV/DEC 2012)
5) How monitors help in process synchronization. [An] (NOV/DEC 2009)
6) Write in detail about deadlock avoidance. [U] (NOV/DEC 2009)
7) Write in detail about deadlock recovery. [U] (APRIL/MAY2011)
8) Explain the Banker algorithm for deadlock avoidance in detail with an example. [Ap]
(APRIL/MAY2010, NOV/DEC 2012) (NOV/DEC 2013)
9) Consider the following set of processes, with the length of the CPU – burst time given in
Milliseconds:
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
The processes are arrived in the order P1, P2, P3, P4, P5, all at time 0.
1. Draw 4 Gantt charts illustrating the execution of these processes using FCFS, SJF Priority and RR
(Time Slice = 1) scheduling
2. What is the turnaround time of each process for each of the scheduling?
3. Calculate the waiting time for each of the process [E] (MAY/JUNE2012) (NOV/DEC2015)
10) Consider the following questions based on the banker‘s algorithm:[E] (MAY/JUNE 2012)
Process Allocation Max Available
P0 A B C D A B C D A B C D
P1 0 0 1 2 0 0 1 2 1 5 2 0
P2 1 0 0 0 1 7 5 0
P3 1 3 5 4 2 3 5 6
P4 0 6 3 2 0 6 5 2
P5 0 0 1 4 0 6 5 6
A B C A B C A B C
P0 0 1 0 7 5 3 3 3 2
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
12) Discuss the threading issues which are considered with multithreaded programs.
[An] MAY/JUNE 2014)(APRIL/MAY2011, MAY/JUNE 2012)
Consider the following snapshot of a system:
P0-P4 are 5 processes present and A, B, C, D are the resources .The maximum need of a process and the
allocated resources details are given in the table.
Allocation Max Available
A B C D A B C D A B C D
P0 0 0 1 2 0 0 1 2 1 5 2 0
P1 1 0 0 0 1 7 5 0
P2 1 3 5 4 2 3 5 6
P3 0 6 3 2 0 6 5 2
P4 1 0 1 4 0 6 5 6
P1 0 10
P2 1 6
P3 2 12
P4 3 15
R1 R2 R3 R1 R2 R3
P1 2 2 3 3 6 8
P2 2 0 3 4 3 3
P3 1 2 4 3 4 4
18) Is the current allocation in a safe state? [E] (NOV/DEC 2015) [An] (MAY/JUNE 2016)
20) (i) Is it possible to have concurrency but not parallelism? Explain.
(ii) Consider a system consisting of four resources of the same type that are shared by three processes, each of
which needs at most two resources. Show that the system is deadlock free.
(i) Describe the actions taken by a kernel to context-switch between processes.
(ii) Provide two programming examples in which multithreading does not provide better performance
than a single-threaded solution. [An] (MAY/JUNE 2016)
19) (i) Give an example of a situation in which ordinary pipes are more suitable than named pipes and an
example of a situation in which named pipes are more suitable than ordinary pipes. (8) (NOV/DEC 2016) [An]
(ii) Describe the differences among short-term, medium-term, and long term scheduling [U](8)
(NOV/DEC 2016)
20) (i) Explain why interrupts are not appropriate for implementing synchronization primitives in
multiprocessor systems[An] (8) (NOV/DEC 2016)
(i) What are the different thread libraries used? Explain any one with example [An](8)
(NOV/DEC 2016)
21) Consider the following set of processes, with the length of the CPU-burst time in given ms:
A B C D A B C D A B C D
P0 2 0 0 1 4 2 1 2 3 3 2 1
P1 3 1 2 1 5 2 5 2
P2 2 1 0 3 2 3 1 6
P3 1 3 1 2 1 4 2 4
P4 1 4 3 2 3 6 6 5
P1 10 3 0
P2 1 1 1
P3 2 3 2
P4 1 4 1
P5 5 2 2
Draw the Gantt chart for the execution of these processes using FCFS, SJF, SRTS, pre- emptive and non-pre-
emptive priority, round robin with time slice of 2 ms. Find the average waiting and turnaround time using each of
the methods. (10)
(ii)Explain Multi level queue and multi-level feedback queue scheduling with suitable example. (5)
(APR/MAY 2019)
36) (i) Consider two processes, p1 and p2 where p1 = 50, t1 = 25, p2 = -75 and t2 = 30. Can these two processes be
scheduled using rate-monotonic scheduling and earliest deadline first scheduling. Illustrate your answer using
Gantt charts. (10)
(ii) Explain in detail about paging in 32 bit and 64 bit architectures. (5) (APR/MAY 2019)
37) (i) Explain banker algorithm for deadlock avoidance with suitable example. (7)
(ii) A system has four processes and five resources. The current allocation and maximum need are as
follows (NOV/DEC 2021)
Consider value of x as 1,2,3.What is the smallest value of x in which the above system become a safe state?
38) (i) What is critical section? Discuss in detail reader‘s writer‘s problem. (7) (NOV/DEC 2021)
(ii) Define Deadlock. State the condition for deadlock. Explain the steps involved in deadlock recovery. (6)