Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  A system has n resources R0,...,Rn-1,and k pr... Start Learning for Free
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?
  • a)
    n=40, k=26
  • b)
    n=21, k=12
  • c)
    n=20, k=10
  • d)
    n=41, k=19
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1.The i...
Option B is answer
No. of resources, n = 21
No. of processes, k = 12
Processes {P0, P1....P11}  make the following Resource requests:
{R0, R20, R2, R18, R4, R16, R6, R14, R8, R12, R10, R10}
For example P0 will request R0 (0%2 is = 0 and 0< n=21). 
Similarly, P10 will request R10.
P11 will request R10 as n - i = 21 - 11 = 10.
As different processes are requesting the same resource, deadlock
may occur. 
View all questions of this test
Most Upvoted Answer
A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1.The i...
The resource request logic for each process Pi in the given system can be represented as follows:

if (i % 2 == 0) {
if (i < n)="" />
acquire_resource(Ri);
} else {
wait();
}
} else {
if (i < n)="" />
if (i + 1 < n)="" />
acquire_resource(Ri);
acquire_resource(Ri+1);
} else {
wait();
}
} else {
release_resource(Ri-n);
release_resource(Ri-n+1);
}
}

Explanation:

1. If the process index i is even:
- If i is less than the total number of resources n, the process acquires the resource Ri.
- Otherwise, the process waits as it does not have a corresponding resource.

2. If the process index i is odd:
- If i is less than the total number of resources n, the process tries to acquire two consecutive resources Ri and Ri+1.
- If i+1 is less than n, both resources are acquired.
- Otherwise, the process waits as it does not have a corresponding resource.
- If i is greater than or equal to n, the process releases two resources Ri-n and Ri-n+1. These resources are returned to the system for other processes to use.

Note: The resource indexes are calculated modulo n to ensure that the process uses valid resource indexes within the range of 0 to n-1.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer?
Question Description
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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer?.
Solutions for 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer?, a detailed solution for 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice 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?a)n=40, k=26b)n=21, k=12c)n=20, k=10d)n=41, k=19Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev