• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

50 Operating System MCQs with Answers

Question 11

Processes P1 and P2 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 P1 and P2 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

Question 12

A system contains three programs and each requires three tape units for its operation. The minimum number of tape units which the system must have such that deadlocks never arise is _________.
  • 6
  • 7
  • 8
  • 9

Question 13

Let m[0]…m[4] be mutexes (binary semaphores) and P[0] …. P[4] be processes. Suppose each process P[i] executes the following:
  wait (m[i]); wait(m[(i+1) mode 4]);

  ------

  release (m[i]); release (m[(i+1)mod 4]); 
This could cause:
  • Thrashing
  • Deadlock
  • Starvation, but not deadlock
  • None of the above

Question 14

A system has 6 identical resources and N processes competing for them. Each process can request atmost 2 resources. Which one of the following values of N could lead to a deadlock?

  • 1

  • 2

  • 3

  • 4

Question 15

Consider the following policies for preventing deadlock in a system with mutually exclusive resources.
I. Processes should acquire all their resources at the 
   beginning of execution.  If any resource is not  
   available, all resources acquired so far are released.
II. The resources are numbered uniquely, and processes are 
    allowed to request for resources only in increasing 
    resource numbers.
III. The resources are numbered uniquely, and processes are
     allowed to request  for resources only in decreasing 
     resource numbers.
IV. The resources are numbered uniquely. A process is allowed
    to request only for a resource with resource number larger
    than its currently held resources.
Which of the above policies can be used for preventing deadlock?
  • Any one of I and III but not II or IV
  • Any one of I, III and IV but not II
  • Any one of II and III but not I or IV
  • Any one of I, II, III and IV

Question 16

A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore is

  • 0

  • 8

  • 10

  • 12

Question 17

An operating system handles requests to resources as follows. A process (which asks for some resources, uses them for some time and then exits the system) is assigned a unique timestamp are when it starts. The timestamps are monotonically increasing with time. Let us denote the timestamp of a process P by TS(P). When a process P requests for a resource the OS does the following:
(i) If no other process is currently holding the resource, the OS awards the resource to P.
(ii) If some process Q with TS(Q)<TS(P) is holding the resource, the OS makes P wait for 
     the resources.
(iii) If some process Q with TS(Q)>TS(P) is holding the resource, the OS restarts Q 
      and awards the resources to P.
(Restarting means taking back the resources held by a process, killing it and starting it 
again with the same timestamp)
When a process releases a resource, the process with the smallest timestamp (if any) amongst those waiting for the resource is awarded the resource. a). Can a deadlock ever arise? If yes, show how. If not, prove it. b). Can a process P ever starve? If yes, show how. If not, prove it.

    Question 18

    A critical section is a program segment
    • which should run in a certain specified amount of time
    • which avoids deadlocks
    • where shared resources are accessed
    • which must be enclosed by a pair of semaphore operations, P and V

    Question 19

    Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is N. Three semaphores empty, full and mutex are defined with respective initial values of 0, N and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().

    [caption width="800"] [/caption]

    Which one of the following assignments to P, Q, R and S will yield the correct solution? 

    • P: full, Q: full, R: empty, S: empty

    • P: empty, Q: empty, R: full, S: full

    • P: full, Q: empty, R: empty, S: full

    • P: empty, Q: full, R: full, S: empty

    Question 20

    Which of the following is not true with respect to deadlock prevention and deadlock avoidance schemes?
    • In deadlock prevention, the request for resources is always granted if resulting state is safe
    • In deadlock avoidance, the request for resources is always granted, if the resulting state is safe
    • Deadlock avoidance requires knowledge of resource requirements a priori
    • Deadlock prevention is more restrictive than deadlock avoidance

    There are 50 questions to complete.

    Last Updated :
    Take a part in the ongoing discussion