Chapter 5: Process Synchronization: 1. The Critical Section (CS) Problem and Solutions

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

Chapter 5: Process Synchronization

1. The Critical Section (CS) Problem and Solutions

1. Concurrent access to shared data may result in ____________


a) data consistency
b) data insecurity
c) data inconsistency
d) none of the mentioned

2. A situation where several processes access and manipulate the same data concurrently and the outcome of
the execution depends on the particular order in which access takes place is called ____________
a) data consistency
b) race condition
c) aging
d) starvation

3. The segment of code in which the process may change common variables, update tables, write into files is
known as ____________
a) program
b) critical section
c) non – critical section
d) synchronizing

4. Which of the following conditions must be satisfied to solve the critical section problem?
a) Mutual Exclusion
b) Progress
c) Bounded Waiting
d) All of the mentioned

5. Mutual exclusion implies that ____________


a) if a process is executing in its critical section, then no other process must be executing in their
critical sections
b) if a process is executing in its critical section, then other processes must be executing in their critical
sections
c) if a process is executing in its critical section, then all the resources of the system must be blocked until it
finishes execution
d) none of the mentioned

6. Bounded waiting implies that there exists a bound on the number of times a process is allowed to enter its
critical section ____________
a) after a process has made a request to enter its critical section and before the request is granted
b) when another process is in its critical section
c) before a process has made a request to enter its critical section
d) none of the mentioned
7. A minimum of _____ variable(s) is/are required to be shared between processes to solve the critical
section problem.
a) one
b) two
c) three
d) four

8. In the bakery algorithm to solve the critical section problem ____________


a) each process is put into a queue and picked up in an ordered manner
b) each process receives a number (may or may not be unique) and the one with the lowest number is
served next
c) each process gets a unique number and the one with the highest number is served next
d) each process gets a unique number and the one with the lowest number is served next

2. The Classic Synchronization Problems

1. The bounded buffer problem is also known as ____________


a) Readers – Writers problem
b) Dining – Philosophers problem
c) Producer – Consumer problem
d) None of the mentioned

2. In the bounded buffer problem, there are the empty and full semaphores that ____________
a) count the number of empty and full buffers
b) count the number of empty and full memory spaces
c) count the number of empty and full queues
d) none of the mentioned

3. In the bounded buffer problem ____________


a) there is only one buffer
b) there are n buffers ( n being greater than one but finite)
c) there are infinite buffers
d) the buffer size is bounded

4. To ensure difficulties do not arise in the readers – writers problem _______ are given exclusive access to
the shared object.
a) readers
b) writers
c) readers and writers
d) none of the mentioned

5. The dining – philosophers problem will occur in case of ____________


a) 5 philosophers and 5 chopsticks
b) 4 philosophers and 5 chopsticks
c) 3 philosophers and 5 chopsticks
d) 6 philosophers and 5 chopsticks
6. A deadlock free solution to the dining philosophers problem ____________
a) necessarily eliminates the possibility of starvation
b) does not necessarily eliminate the possibility of starvation
c) eliminates any possibility of any kind of problem further
d) none of the mentioned

7. All processes share a semaphore variable mutex, initialized to 1. Each process must execute wait(mutex)
before entering the critical section and signal(mutex) afterward.
Suppose a process executes in the following manner.

signal(mutex);
.....
critical section
.....
wait(mutex);

In this situation :
a) a deadlock will occur
b) processes will starve to enter critical section
c) several processes maybe executing in their critical section
d) all of the mentioned

8. All processes share a semaphore variable mutex, initialized to 1. Each process must execute wait(mutex)
before entering the critical section and signal(mutex) afterward.
Suppose a process executes in the following manner.

wait(mutex);
.....
critical section
.....
wait(mutex);

a) a deadlock will occur


b) processes will starve to enter critical section
c) several processes maybe executing in their critical section
d) all of the mentioned

9. Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed,
as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned. (GATE
2010)

Method used by P1 :
while(S1==S2);
Critical section
S1 = S2;
Method used by P2 :
while(S1!=S2);
Critical section
S2 = not(S1);

Which of the following statements describes properties achieved?


a) Mutual exclusion but not progress
b) Progress but not mutual exclusion
c) Neither mutual exclusion nor progress
d) Both mutual exclusion and progress
3. Semaphores – 1

1. An un-interruptible unit is known as ____________


a) single
b) atomic
c) static
d) none of the mentioned

2. TestAndSet instruction is executed ____________


a) after a particular process
b) periodically
c) atomically
d) none of the mentioned

3. Semaphore is a/an _______ to solve the critical section problem.


a) hardware for a system
b) special program for a system
c) integer variable
d) none of the mentioned

4. What are the two atomic operations permissible on semaphores?


a) wait
b) stop
c) hold
d) none of the mentioned

5. What are Spinlocks?


a) CPU cycles wasting locks over critical sections of programs
b) Locks that avoid time wastage in context switches
c) Locks that work better on multiprocessor systems
d) All of the mentioned

6. What is the main disadvantage of spinlocks?


a) they are not sufficient for many process
b) they require busy waiting
c) they are unreliable sometimes
d) they are too complex for programmers

7. The wait operation of the semaphore basically works on the basic _______ system call.
a) stop()
b) block()
c) hold()
d) wait()
8. The signal operation of the semaphore basically works on the basic _______ system call.
a) continue()
b) wakeup()
c) getup()
d) start()

9. If the semaphore value is negative ____________


a) its magnitude is the number of processes waiting on that semaphore
b) it is invalid
c) no operation can be further performed on it until the signal operation is performed on it
d) none of the mentioned

10. The code that changes the value of the semaphore is ____________
a) remainder section code
b) non – critical section code
c) critical section code
d) none of the mentioned

11. The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are
initialized as S0 = 1, S1 = 0, S2 = 0.

Process P0
while(true)
{
wait(S0);
print '0';
release(S1);
release(S2);
}

Process P1
wait(S1);
release(S0);

Process P2
wait(S2);
release(S0);

How many times will P0 print ‘0’?


a) At least twice
b) Exactly twice
c) Exactly thrice
d) Exactly once
12. Each process Pi, i = 0,1,2,3,……,9 is coded as follows.

repeat
P(mutex)
{Critical Section}
V(mutex)
forever

The code for P10 is identical except that it uses V(mutex) instead of P(mutex). What is the largest number of
processes that can be inside the critical section at any moment (the mutex being initialized to 1)?
a) 1
b) 2
c) 3
d) None of the mentioned
Explanation: Any one of the 9 processes can get into critical section after executing P(mutex) which
decrements the mutex value to 0. At this time P10 can enter critical section by incrementing the value to 1.
Now any of the 9 processes can enter the critical section by again decrementing the mutex value to 0. None
of the remaining processes can get into their critical sections.

13. Two processes, P1 and P2, need to access a critical section of code. Consider the following
synchronization construct used by the processes.

Process P1 :
while(true)
{
w1 = true;
while(w2 == true);
Critical section
w1 = false;
}
Remainder Section

Process P2 :
while(true)
{
w2 = true;
while(w1 == true);
Critical section
w2 = false;
}
Remainder Section

Here, w1 and w2 have shared variables, which are initialized to false. Which one of the following statements
is TRUE about the above construct?
a) It does not ensure mutual exclusion
b) It does not ensure bounded waiting
c) It requires that processes enter the critical section in strict alternation
d) It does not prevent deadlocks but ensures mutual exclusion

4. Semaphores – 2

1. What will happen if a non-recursive mutex is locked more than once?


a) Starvation
b) Deadlock
c) Aging
d) Signaling
Explanation: If a thread which had already locked a mutex, tries to lock the mutex again, it will enter into
the waiting list of that mutex, which results in a deadlock. It is because no other thread can unlock the
mutex.
2. What is a semaphore?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned

3. What are the two kinds of semaphores?


a) mutex & counting
b) binary & counting
c) counting & decimal
d) decimal & binary

4. What is a mutex?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned

5. At a particular time of computation the value of a counting semaphore is 7.Then 20 P operations and 15 V
operations were completed on this semaphore. The resulting value of the semaphore is? (GATE 1987)
a) 42
b) 2
c) 7
d) 12
Explanation: P represents Wait and V represents Signal. P operation will decrease the value by 1 every time
and V operation will increase the value by 1 every time.

6. A binary semaphore is a semaphore with integer values ____________


a) 1
b) -1
c) 0.8
d) 0.5

7. The following pair of processes share a common variable X.

Process A
int Y;
A1: Y = X*2;
A2: X = Y;

Process B
int Z;
B1: Z = X+1;
B2: X = Z;

X is set to 5 before either process begins execution. As usual, statements within a process are executed
sequentially, but statements in process A may execute in any order with respect to statements in process B.
How many different values of X are possible after both processes finish executing?
a) two
b) three
c) four
d) eight
Explanation: Here are the possible ways in which statements from A and B can be interleaved.
A1 A2 B1 B2: X = 11
A1 B1 A2 B2: X = 6
A1 B1 B2 A2: X = 10
B1 A1 B2 A2: X = 10
B1 A1 A2 B2: X = 6
B1 B2 A1 A2: X = 12.

8. The program follows to use a shared binary semaphore T.

Process A
int Y;
A1: Y = X*2;
A2: X = Y;
signal(T);

Process B
int Z;
B1: wait(T);
B2: Z = X+1;
X = Z;

T is set to 0 before either process begins execution and, as before, X is set to 5.


Now, how many different values of X are possible after both processes finish executing?
a) one
b) two
c) three
d) four
Explanation: The semaphore T ensures that all the statements from A finish execution before B begins. So
now there is only one way in which statements from A and B can be interleaved:
A1 A2 B1 B2: X = 11.

9. Semaphores are mostly used to implement ____________


a) System calls
b) IPC mechanisms
c) System protection
d) None of the mentioned

10. Spinlocks are intended to provide __________ only.


a) Mutual Exclusion
b) Bounded Waiting
c) Aging
d) Progress

5. Monitors

1. A monitor is a type of ____________


a) semaphore
b) low level synchronization construct
c) high level synchronization construct
d) none of the mentioned
2. A monitor is characterized by ____________
a) a set of programmer defined operators
b) an identifier
c) the number of variables in it
d) all of the mentioned

3. A procedure defined within a ________ can access only those variables declared locally within the
_______ and its formal parameters.
a) process, semaphore
b) process, monitor
c) semaphore, semaphore
d) monitor, monitor

4. The monitor construct ensures that ____________


a) only one process can be active at a time within the monitor
b) n number of processes can be active at a time within the monitor (n being greater than 1)
c) the queue has only one process in it at a time
d) all of the mentioned

5. What are the operations that can be invoked on a condition variable?


a) wait & signal
b) hold & wait
c) signal & hold
d) continue & signal

6. Which is the process of invoking the wait operation?


a) suspended until another process invokes the signal operation
b) waiting for another process to complete before it can itself call the signal operation
c) stopped until the next process in the queue finishes execution
d) none of the mentioned

7. If no process is suspended, the signal operation ____________


a) puts the system into a deadlock state
b) suspends some default process execution
c) nothing happens
d) the output is unpredictable

6. Atomic Transactions

1. A collection of instructions that performs a single logical function is called ____________


a) transaction
b) operation
c) function
d) all of the mentioned
2. A terminated transaction that has completed its execution successfully is ____________ otherwise it is
__________
a) committed, destroyed
b) aborted, destroyed
c) committed, aborted
d) none of the mentioned

3. The state of the data accessed by an aborted transaction must be restored to what it was just before the
transaction started executing. This restoration is known as ________ of transaction.
a) safety
b) protection
c) roll – back
d) revert – back

4. Write ahead logging is a way ____________


a) to ensure atomicity
b) to keep data consistent
c) that records data on stable storage
d) all of the mentioned

5. In the write ahead logging a _____________ is maintained.


a) a memory
b) a system
c) a disk
d) a log record

6. An actual update is not allowed to a data item ____________


a) before the corresponding log record is written out to stable storage
b) after the corresponding log record is written out to stable storage
c) until the whole log record has been checked for inconsistencies
d) all of the mentioned

7. The undo and redo operations must be _________ to guarantee correct behaviour, even if a failure occurs
during recovery process.
a) idempotent
b) easy
c) protected
d) all of the mentioned
Explanation: Idempotent – Multiple executions of an operation have the same result as does one execution.

8. The system periodically performs checkpoints that consists of the following operation(s) ____________
a) Putting all the log records currently in main memory onto stable storage
b) putting all modified data residing in main memory onto stable storage
c) putting a log record onto stable storage
d) all of the mentioned
9. Consider a transaction T1 that committed prior to checkpoint. The <T1 commits> record appears in the
log before the <checkpoint> record. Any modifications made by T1 must have been written to the stable
storage either with the checkpoint or prior to it. Thus at recovery time ____________
a) There is a need to perform an undo operation on T1
b) There is a need to perform a redo operation on T1
c) There is no need to perform an undo and redo operation on T1
d) All of the mentioned

10. Serializable schedules are ones where ____________


a) concurrent execution of transactions is equivalent to the transactions executed serially
b) the transactions can be carried out one after the other
c) a valid result occurs after execution transactions
d) none of the mentioned

11. A locking protocol is one that ____________


a) governs how locks are acquired
b) governs how locks are released
c) governs how locks are acquired and released
d) none of the mentioned

12. The two phase locking protocol consists of ____________


a) growing & shrinking phase
b) shrinking & creation phase
c) creation & growing phase
d) destruction & creation phase

13. The growing phase is a phase in which?


a) A transaction may obtain locks, but does not release any
b) A transaction may obtain locks, and releases a few or all of them
c) A transaction may release locks, but does not obtain any new locks
d) A transaction may release locks, and does obtain new locks

14. The shrinking phase is a phase in which?


a) A transaction may obtain locks, but does not release any
b) A transaction may obtain locks, and releases a few or all of them
c) A transaction may release locks, but does not obtain any new locks
d) A transaction may release locks, and does obtain new locks

15. Which of the following concurrency control protocols ensure both conflict serializability and freedom
from deadlock?
I) 2-phase locking
II) Timestamp ordering
a) I only
b) II only
c) Both I and II
d) Neither I nor II
Chapter 6: CPU Scheduling
1. CPU Scheduling

1. Which module gives control of the CPU to the process selected by the short-term scheduler?
a) dispatcher
b) interrupt
c) scheduler
d) none of the mentioned

2. The processes that are residing in main memory and are ready and waiting to execute are kept on a list
called _____________
a) job queue
b) ready queue
c) execution queue
d) process queue

3. The interval from the time of submission of a process to the time of completion is termed as
____________
a) waiting time
b) turnaround time
c) response time
d) throughput

4. Which scheduling algorithm allocates the CPU first to the process that requests the CPU first?
a) first-come, first-served scheduling
b) shortest job scheduling
c) priority scheduling
d) none of the mentioned

5. In priority scheduling algorithm ____________


a) CPU is allocated to the process with highest priority
b) CPU is allocated to the process with lowest priority
c) Equal priority processes can not be scheduled
d) None of the mentioned

6. In priority scheduling algorithm, when a process arrives at the ready queue, its priority is compared with
the priority of ____________
a) all process
b) currently running process
c) parent process
d) init process

7. Which algorithm is defined in Time quantum?


a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
8. Process are classified into different groups in ____________
a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm

9. In multilevel feedback scheduling algorithm ____________


a) a process can move to a different classified ready queue
b) classification of ready queue is permanent
c) processes are not classified into groups
d) none of the mentioned

10. Which one of the following can not be scheduled by the kernel?
a) kernel level thread
b) user level thread
c) process
d) none of the mentioned

2. CPU Scheduling Benefits

1. CPU scheduling is the basis of ___________


a) multiprocessor systems
b) multiprogramming operating systems
c) larger memory sized systems
d) none of the mentioned

2. With multiprogramming ______ is used productively.


a) time
b) space
c) money
d) all of the mentioned

3. What are the two steps of a process execution?


a) I/O & OS Burst
b) CPU & I/O Burst
c) Memory & I/O Burst
d) OS & Memory Burst

4. An I/O bound program will typically have ____________


a) a few very short CPU bursts
b) many very short I/O bursts
c) many very short CPU bursts
d) a few very short I/O bursts
5. A process is selected from the ______ queue by the ________ scheduler, to be executed.
a) blocked, short term
b) wait, long term
c) ready, short term
d) ready, long term

6. In the following cases non – preemptive scheduling occurs?


a) When a process switches from the running state to the ready state
b) When a process goes from the running state to the waiting state
c) When a process switches from the waiting state to the ready state
d) All of the mentioned

7. The switching of the CPU from one process or thread to another is called ____________
a) process switch
b) task switch
c) context switch
d) all of the mentioned

8. What is Dispatch latency?


a) the speed of dispatching a process from running to the ready state
b) the time of dispatching a process from running to ready state and keeping the CPU idle
c) the time to stop one process and start running another one
d) none of the mentioned

9. Scheduling is done so as to ____________


a) increase CPU utilization
b) decrease CPU utilization
c) keep the CPU more idle
d) none of the mentioned

10. Scheduling is done so as to ____________


a) increase the throughput
b) decrease the throughput
c) increase the duration of a specific amount of work
d) none of the mentioned

11. What is Turnaround time?


a) the total waiting time for a process to finish execution
b) the total time spent in the ready queue
c) the total time spent in the running queue
d) the total time from the completion till the submission of a process

12. Scheduling is done so as to ____________


a) increase the turnaround time
b) decrease the turnaround time
c) keep the turnaround time same
d) there is no relation between scheduling and turnaround time
13. What is Waiting time?
a) the total time in the blocked and waiting queues
b) the total time spent in the ready queue
c) the total time spent in the running queue
d) the total time from the completion till the submission of a process

14. Scheduling is done so as to ____________


a) increase the waiting time
b) keep the waiting time the same
c) decrease the waiting time
d) none of the mentioned

15. What is Response time?


a) the total time taken from the submission time till the completion time
b) the total time taken from the submission time till the first response is produced
c) the total time taken from submission time till the response is output
d) none of the mentioned

3. CPU Scheduling Algorithms-1

1. Round robin scheduling falls under the category of ____________


a) Non-preemptive scheduling
b) Preemptive scheduling
c) All of the mentioned
d) None of the mentioned

2. With round robin scheduling algorithm in a time shared system ____________


a) using very large time slices converts it into First come First served scheduling algorithm
b) using very small time slices converts it into First come First served scheduling algorithm
c) using extremely small time slices increases performance
d) using very small time slices converts it into Shortest Job First algorithm
Explanation: All the processes will be able to get completed.

3. The portion of the process scheduler in an operating system that dispatches processes is concerned with
____________
a) assigning ready processes to CPU
b) assigning ready processes to waiting queue
c) assigning running processes to blocked queue
d) all of the mentioned

4. Complex scheduling algorithms ____________


a) are very appropriate for very large computers
b) use minimal resources
c) use many resources
d) all of the mentioned
5. What is FIFO algorithm?
a) first executes the job that came in last in the queue
b) first executes the job that came in first in the queue
c) first executes the job that needs minimal processor
d) first executes the job that has maximum processor needs

6. The strategy of making processes that are logically runnable to be suspended is called ____________
a) Non preemptive scheduling
b) Preemptive scheduling
c) Shortest job first
d) First come First served

7. What is Scheduling?
a) allowing a job to use the processor
b) making proper use of processor
c) all of the mentioned
d) none of the mentioned

8. There are 10 different processes running on a workstation. Idle processes are waiting for an input event in
the input queue. Busy processes are scheduled with the Round-Robin time sharing method. Which out of the
following quantum times is the best value for small response times, if the processes have a short runtime,
e.g. less than 10ms?
a) tQ = 15ms
b) tQ = 40ms
c) tQ = 45ms
d) tQ = 50ms

9. Orders are processed in the sequence they arrive if _______ rule sequences the jobs.
a) earliest due date
b) slack time remaining
c) first come, first served
d) critical ratio

10. Which of the following algorithms tends to minimize the process flow time?
a) First come First served
b) Shortest Job First
c) Earliest Deadline First
d) Longest Job First

11. Under multiprogramming, turnaround time for short jobs is usually ________ and that for long jobs is
slightly ___________
a) Lengthened; Shortened
b) Shortened; Lengthened
c) Shortened; Shortened
d) Shortened; Unchanged
12. Which of the following statements are true? (GATE 2010)

I. Shortest remaining time first scheduling may cause starvation


II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time

a) I only
b) I and III only
c) II and III only
d) I, II and III

4. CPU Scheduling Algorithms-2

1. Which is the most optimal scheduling algorithm?


a) FCFS – First come First served
b) SJF – Shortest Job First
c) RR – Round Robin
d) None of the mentioned

2. The real difficulty with SJF in short term scheduling is ____________


a) it is too good an algorithm
b) knowing the length of the next CPU request
c) it is too complex to understand
d) none of the mentioned

3. The FCFS algorithm is particularly troublesome for ____________


a) time sharing systems
b) multiprogramming systems
c) multiprocessor systems
d) operating systems
Explanation: In a time sharing system, each user needs to get a share of the CPU at regular intervals.

4. Consider the following set of processes, the length of the CPU burst time given in milliseconds.

Process Burst time


P1 6
P2 8
P3 7
P4 3

Assuming the above process being scheduled with the SJF scheduling algorithm.
a) The waiting time for process P1 is 3ms
b) The waiting time for process P1 is 0ms
c) The waiting time for process P1 is 16ms
d) The waiting time for process P1 is 9ms

5. Preemptive Shortest Job First scheduling is sometimes called ____________


a) Fast SJF scheduling
b) EDF scheduling – Earliest Deadline First
c) HRRN scheduling – Highest Response Ratio Next
d) SRTN scheduling – Shortest Remaining Time Next
6. An SJF algorithm is simply a priority algorithm where the priority is ____________
a) the predicted next CPU burst
b) the inverse of the predicted next CPU burst
c) the current CPU burst
d) anything the user wants
Explanation: The larger the CPU burst, the lower the priority.

7. Choose one of the disadvantages of the priority scheduling algorithm?


a) it schedules in a very complex manner
b) its scheduling takes up a lot of time
c) it can lead to some low priority process waiting indefinitely for the CPU
d) none of the mentioned

8. What is ‘Aging’?
a) keeping track of cache contents
b) keeping track of what pages are currently residing in memory
c) keeping track of how many times a given page is referenced
d) increasing the priority of jobs to ensure termination in a finite time

9. A solution to the problem of indefinite blockage of low – priority processes is ____________


a) Starvation
b) Wait queue
c) Ready queue
d) Aging

10. Which of the following statements are true? (GATE 2010)

i) Shortest remaining time first scheduling may cause starvation


ii) Preemptive scheduling may cause starvation
iii) Round robin is better than FCFS in terms of response time

a) i only
b) i and iii only
c) ii and iii only
d) i, ii and iii

11. Which of the following scheduling algorithms gives minimum average waiting time?
a) FCFS
b) SJF
c) Round – robin
d) Priority
Chapter 7: Deadlocks
1. Deadlock

1. What is a reusable resource?


a) that can be used by one process at a time and is not depleted by that use
b) that can be used by more than one process at a time
c) that can be shared between various threads
d) none of the mentioned

2. Which of the following condition is required for a deadlock to be possible?


a) mutual exclusion
b) a process may hold allocated resources while awaiting assignment of other resources
c) no resource can be forcibly removed from a process holding it
d) all of the mentioned

3. A system is in the safe state if ____________


a) the system can allocate resources to each process in some order and still avoid a deadlock
b) there exist a safe sequence
c) all of the mentioned
d) none of the mentioned

4. The circular wait condition can be prevented by ____________


a) defining a linear ordering of resource types
b) using thread
c) using pipes
d) all of the mentioned

5. Which one of the following is the deadlock avoidance algorithm?


a) banker’s algorithm
b) round-robin algorithm
c) elevator algorithm
d) karn’s algorithm

6. What is the drawback of banker’s algorithm?


a) in advance processes rarely know how much resource they will need
b) the number of processes changes as time progresses
c) resource once available can disappear
d) all of the mentioned

7. For an effective operating system, when to check for deadlock?


a) every time a resource request is made
b) at fixed time intervals
c) every time a resource request is made at fixed time intervals
d) none of the mentioned
8. A problem encountered in multitasking when a process is perpetually denied necessary resources is called
____________
a) deadlock
b) starvation
c) inversion
d) aging

9. Which one of the following is a visual ( mathematical ) way to determine the deadlock occurrence?
a) resource allocation graph
b) starvation graph
c) inversion graph
d) none of the mentioned

10. To avoid deadlock ____________


a) there must be a fixed number of resources to allocate
b) resource allocation must be done only once
c) all deadlocked processes must be aborted
d) inversion technique can be used

2. Deadlock Detection

1. The wait-for graph is a deadlock detection algorithm that is applicable when ____________
a) all resources have a single instance
b) all resources have multiple instances
c) all resources have a single 7 multiple instances
d) all of the mentioned

2. An edge from process Pi to Pj in a wait for graph indicates that ____________


a) Pi is waiting for Pj to release a resource that Pi needs
b) Pj is waiting for Pi to release a resource that Pj needs
c) Pi is waiting for Pj to leave the system
d) Pj is waiting for Pi to leave the system

3. If the wait for graph contains a cycle ____________


a) then a deadlock does not exist
b) then a deadlock exists
c) then the system is in a safe state
d) either deadlock exists or system is in a safe state

4. If deadlocks occur frequently, the detection algorithm must be invoked ________


a) rarely
b) frequently
c) rarely & frequently
d) none of the mentioned
5. What is the disadvantage of invoking the detection algorithm for every request?
a) overhead of the detection algorithm due to consumption of memory
b) excessive time consumed in the request to be allocated memory
c) considerable overhead in computation time
d) all of the mentioned

6. A deadlock eventually cripples system throughput and will cause the CPU utilization to ______
a) increase
b) drop
c) stay still
d) none of the mentioned

7. Every time a request for allocation cannot be granted immediately, the detection algorithm is invoked.
This will help identify ____________
a) the set of processes that have been deadlocked
b) the set of processes in the deadlock queue
c) the specific process that caused the deadlock
d) all of the mentioned

8. A computer system has 6 tape drives, with ‘n’ processes competing for them. Each process may need 3
tape drives. The maximum value of ‘n’ for which the system is guaranteed to be deadlock free is?
a) 2
b) 3
c) 4
d) 1

9. A system has 3 processes sharing 4 resources. If each process needs a maximum of 2 units then, deadlock
____________
a) can never occur
b) may occur
c) has to occur
d) none of the mentioned

10. ‘m’ processes share ‘n’ resources of the same type. The maximum need of each process doesn’t exceed
‘n’ and the sum of all their maximum needs is always less than m+n. In this setup, deadlock ____________
a) can never occur
b) may occur
c) has to occur
d) none of the mentioned
3. Deadlock Prevention

1. The number of resources requested by a process ____________


a) must always be less than the total number of resources available in the system
b) must always be equal to the total number of resources available in the system
c) must not exceed the total number of resources available in the system
d) must exceed the total number of resources available in the system

2. The request and release of resources are ___________


a) command line statements
b) interrupts
c) system calls
d) special programs

3. What are Multithreaded programs?


a) lesser prone to deadlocks
b) more prone to deadlocks
c) not at all prone to deadlocks
d) none of the mentioned
Explanation: Multiple threads can compete for shared resources.

4. For a deadlock to arise, which of the following conditions must hold simultaneously?
a) Mutual exclusion
b) No preemption
c) Hold and wait
d) All of the mentioned

5. For Mutual exclusion to prevail in the system ____________


a) at least one resource must be held in a non sharable mode
b) the processor must be a uniprocessor rather than a multiprocessor
c) there must be at least one resource in a sharable mode
d) all of the mentioned
Explanation: If another process requests that resource (non – shareable resource), the requesting process
must be delayed until the resource has been released.

6. For a Hold and wait condition to prevail ____________


a) A process must be not be holding a resource, but waiting for one to be freed, and then request to acquire it
b) A process must be holding at least one resource and waiting to acquire additional resources that
are being held by other processes
c) A process must hold at least one resource and not be waiting to acquire additional resources
d) None of the mentioned

7. Deadlock prevention is a set of methods ____________


a) to ensure that at least one of the necessary conditions cannot hold
b) to ensure that all of the necessary conditions do not hold
c) to decide if the requested resources for a process have to be given or not
d) to recover from a deadlock
8. For non sharable resources like a printer, mutual exclusion ____________
a) must exist
b) must not exist
c) may exist
d) none of the mentioned
Explanation: A printer cannot be simultaneously shared by several processes.

9. For sharable resources, mutual exclusion ____________


a) is required
b) is not required
c) may be or may not be required
d) none of the mentioned
Explanation: They do not require mutually exclusive access, and hence cannot be involved in a deadlock.

10. To ensure that the hold and wait condition never occurs in the system, it must be ensured that
____________
a) whenever a resource is requested by a process, it is not holding any other resources
b) each process must request and be allocated all its resources before it begins its execution
c) a process can request resources only when it has none
d) all of the mentioned
Explanation: c – A process may request some resources and use them. Before it can can request any
additional resources, however it must release all the resources that it is currently allocated.

11. The disadvantage of a process being allocated all its resources before beginning its execution is
____________
a) Low CPU utilization
b) Low resource utilization
c) Very high resource utilization
d) None of the mentioned

12. To ensure no preemption, if a process is holding some resources and requests another resource that
cannot be immediately allocated to it ____________
a) then the process waits for the resources be allocated to it
b) the process keeps sending requests until the resource is allocated to it
c) the process resumes execution without the resource being allocated to it
d) then all resources currently being held are preempted

13. One way to ensure that the circular wait condition never holds is to ____________
a) impose a total ordering of all resource types and to determine whether one precedes another in the
ordering
b) to never let a process acquire resources that are held by other processes
c) to let a process wait for only one resource at a time
d) all of the mentioned

4. Deadlock Recovery

1. A deadlock can be broken by ____________


a) abort one or more processes to break the circular wait
b) abort all the process in the system
c) preempt all resources from all processes
d) none of the mentioned
2. The two ways of aborting processes and eliminating deadlocks are ____________
a) Abort all deadlocked processes
b) Abort all processes
c) Abort one process at a time until the deadlock cycle is eliminated
d) All of the mentioned

3. Those processes should be aborted on occurrence of a deadlock, the termination of which?


a) is more time consuming
b) incurs minimum cost
c) safety is not hampered
d) all of the mentioned

4. The process to be aborted is chosen on the basis of the following factors?


a) priority of the process
b) process is interactive or batch
c) how long the process has computed
d) all of the mentioned

5. Cost factors for process termination include ____________


a) Number of resources the deadlock process is not holding
b) CPU utilization at the time of deadlock
c) Amount of time a deadlocked process has thus far consumed during its execution
d) All of the mentioned

6. If we preempt a resource from a process, the process cannot continue with its normal execution and it
must be ____________
a) aborted
b) rolled back
c) terminated
d) queued

7. To _______ to a safe state, the system needs to keep more information about the states of processes.
a) abort the process
b) roll back the process
c) queue the process
d) none of the mentioned

8. If the resources are always preempted from the same process __________ can occur.
a) deadlock
b) system crash
c) aging
d) starvation

9. What is the solution to starvation?


a) the number of rollbacks must be included in the cost factor
b) the number of resources must be included in resource preemption
c) resource preemption be done instead
d) all of the mentioned
5. Deadlock Avoidance

1. Each request requires that the system consider the _____________ to decide whether the current request
can be satisfied or must wait to avoid a future possible deadlock.
a) resources currently available
b) processes that have previously been in the system
c) resources currently allocated to each process
d) future requests and releases of each process

2. Given a priori information about the ________ number of resources of each type that maybe requested for
each process, it is possible to construct an algorithm that ensures that the system will never enter a deadlock
state.
a) minimum
b) average
c) maximum
d) approximate

3. A deadlock avoidance algorithm dynamically examines the __________ to ensure that a circular wait
condition can never exist.
a) resource allocation state
b) system storage state
c) operating system
d) resources
Explanation: Resource allocation states are used to maintain the availability of the already and current
available resources.

4. A state is safe, if ____________


a) the system does not crash due to deadlock occurrence
b) the system can allocate resources to each process in some order and still avoid a deadlock
c) the state keeps the system protected and safe
d) all of the mentioned

5. A system is in a safe state only if there exists a ____________


a) safe allocation
b) safe resource
c) safe sequence
d) all of the mentioned

6. All unsafe states are ____________


a) deadlocks
b) not deadlocks
c) fatal
d) none of the mentioned
7. A system has 12 magnetic tape drives and 3 processes : P0, P1, and P2. Process P0 requires 10 tape
drives, P1 requires 4 and P2 requires 9 tape drives.
Process
P0
P1
P2

Maximum needs (process-wise: P0 through P2 top to bottom)


10
4
9

Currently allocated (process-wise)


5
2
2

Which of the following sequence is a safe sequence?


a) P0, P1, P2
b) P1, P2, P0
c) P2, P0, P1
d) P1, P0, P2

8. If no cycle exists in the resource allocation graph ____________


a) then the system will not be in a safe state
b) then the system will be in a safe state
c) all of the mentioned
d) none of the mentioned

9. The resource allocation graph is not applicable to a resource allocation system ____________
a) with multiple instances of each resource type
b) with a single instance of each resource type
c) single & multiple instances of each resource type
d) none of the mentioned

10. The Banker’s algorithm is _____________ than the resource allocation graph algorithm.
a) less efficient
b) more efficient
c) equal
d) none of the mentioned

11. The data structures available in the Banker’s algorithm are ____________
a) Available
b) Need
c) Allocation
d) All of the mentioned

12. The content of the matrix Need is ____________


a) Allocation – Available
b) Max – Available
c) Max – Allocation
d) Allocation – Max
13. A system with 5 processes P0 through P4 and three resource types A, B, C have A with 10 instances, B
with 5 instances, and C with 7 instances. At time t0, the following snapshot has been taken:

Process
P0
P1
P2
P3
P4

Allocation (process-wise : P0 through P4 top TO bottom)


A B C
0 1 0
2 0 0
3 0 2
2 1 1
0 0 2

MAX (process-wise: P0 through P4 top TO bottom)


A B C
7 5 3
3 2 2
9 0 2
2 2 2
4 3 3

Available
A B C
3 3 2

The sequence <P1, P3, P4, P2, P0> leads the system to ____________
a) an unsafe state
b) a safe state
c) a protected state
d) a deadlock

You might also like