50 Operating System MCQs with Answers (original) (raw)
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlockfree order of invoking the P operations by the processes? (GATE CS 2013)
- X: P(a)P(b)P(c) Y:P(b)P(c)P(d) Z:P(c)P(d)P(a)
- X: P(b)P(a)P(c) Y:P(b)P(c)P(d) Z:P(a)P(c)P(d)
- X: P(b)P(a)P(c) Y:P(c)P(b)P(d) Z:P(a)P(c)P(d)
- X: P(a)P(b)P(c) Y:P(c)P(b)P(d) Z:P(c)P(d)P(a)
Processes P
1
and P
2
use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program.
get_exclusive_access ( ) { if (critical _flag == FALSE) { critical_flag = TRUE ; critical_region () ; critical_flag = FALSE; } }
Consider the following statements.
i. It is possible for both P
1
and P
2
to access critical_region concurrently.
ii. This may lead to a deadlock.
Which of the following holds?
- (i) is false and (ii) is true
- Both (i) and (ii) are false
- (i) is true and (ii) is false
- Both (i) and (ii) are true
A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1 .The implementation of the resource request logic of each process Pi is as follows:
if (i % 2 == 0) {
if (i < n) request Ri
if (i+2 < n) request Ri+2
}
else {
if (i < n) request Rn-i
if (i+2 < n) request Rn-i-2
}
In which one of the following situations is a deadlock possible?
Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3 units), R4 (2 units). A non-preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot be completely satisfied. Three processes P1, P2, P3 request the sources as follows if executed independently.
**Process P1:
t=0: requests 2 units of R2
t=1: requests 1 unit of R3
t=3: requests 2 units of R1
t=5: releases 1 unit of R2
and 1 unit of R1.
t=7: releases 1 unit of R3
t=8: requests 2 units of R4
t=10: Finishes
**Process P2:
t=0: requests 2 units of R3
t=2: requests 1 unit of R4
t=4: requests 1 unit of R1
t=6: releases 1 unit of R3
t=8: Finishes
**Process P3:
t=0: requests 1 unit of R4
t=2: requests 2 units of R1
t=5: releases 2 units of R1
t=7: requests 1 unit of R2
t=8: requests 1 unit of R3
t=9: Finishes
Which one of the following statements is TRUE if all three processes run concurrently starting at time t=0?
- All processes will finish without any deadlock
- Only P1 and P2 will be in deadlock.
- Only P1 and P3 will be in a deadlock.
- All three processes will be in deadlock
Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?
- In deadlock prevention, the request for resources is always granted if the resulting state is safe
- In deadlock avoidance, the request for resources is always granted if the result state is safe
- Deadlock avoidance is less restrictive than deadlock prevention
- Deadlock avoidance requires knowledge of resource requirements a priori
In Unix, files can be protected by assigning each one a 9-bit mode called rights bits. Now, consider the following two statements: I. A mode of 641 (octal) means that the owner can read and write the file, other members of the owner’s group can read it, and users can execute only. II. A mode of 100 (octal) allows the owner to execute the file, but prohibits all other access. Which of the following options is correct with reference to above statements ?
- Both I and II are correct.
- Both I and II are incorrect.
Which of the following commands or sequences of commands will rename a file x to file y in a Unix system? I. mv y, x II. mv x, y III. cp y, x (rm x) IV. cp x, y (rm x)
The shell command
find -name passwd -print
is executed in /etc directory of a computer system running Unix. Which of the following shell commands will give the same information as the above command when executed in the same directory?
Consider the following statements :
(a) UNIX provides three types of permissions
* Read
* Write
* Execute
(b) UNIX provides three sets of permissions
* permission for owner
* permission for group
* permission for others
Which of the above statement/s is/are true?
The linux command “mknod myfifo b 4 16”
- Will create a character device if the user is root
- Will create a named pipe FIFO if the user is root
- Will create a block device if the user is root
There are 50 questions to complete.
Take a part in the ongoing discussion