Consider the following snapshot of a system running 𝑛 concurrent processes.…

2019

Consider the following snapshot of a system running 𝑛 concurrent processes. Process 𝑖 is holding 𝑋𝑖 instances of a resource R, 1 ≀ 𝑖 ≀ 𝑛. Assume that all instances of R are currently in use. Further, for all 𝑖, process 𝑖 can place a request for at most π‘Œπ‘– additional instances of R while holding the 𝑋𝑖 instances it already has. Of the 𝑛 processes, there are exactly two processes 𝑝 and π‘ž such that π‘Œπ‘ = π‘Œπ‘ž = 0. Which one of the following conditions guarantees that no other process apart from 𝑝 and π‘ž can complete execution?

  1. A.

    \(X_p + X_q < \text{Min} \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q \}\)

  2. B.

    \(X_p + X_q < \text{Max} \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q \}\)

  3. C.

    \(\text{Min}(X_p,X_q) \geq \text{Min} \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}\)

  4. D.

    \(\text{Min}(X_p,X_q) \leq \text{Max} \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}\)

Attempted by 113 students.

Show answer & explanation

Correct answer: A

Key idea: p and q will not request additional instances and so can complete and free the resources they hold.

  • When p and q finish they free a total of X_p + X_q instances of R.

  • For any other process k, that process may request up to Y_k additional instances while holding its current X_k.

  • To guarantee that no other process can complete, the freed resources must be strictly less than every such possible additional request; i.e., X_p + X_q < Min{Y_k | k β‰  p,q}.

  • Therefore the condition X_p + X_q < Min{Y_k | 1 ≀ k ≀ n, k β‰  p, k β‰  q} guarantees that no process other than p and q can complete.

A video solution is available for this question β€” log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir