Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  A certain computation generates two arrays a ... Start Learning for Free
A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.
Process X:                        Process Y:
private i;                              private i;
for (i=0; i < n; i++) {             for (i=0; i < n; i++) {
     a[i] = f(i);                             EntryY(R, S);
     ExitX(R, S);                        b[i]=g(a[i]);
}                                            }
 
Q. Which one of the following represents the CORRECT implementations of ExitX and EntryY?
  • a)
    ExitX(R, S) {
        P(R);
        V(S);
    }
    EntryY (R, S) {
        P(S);
        V(R);
    }
  • b)
    ExitX(R, S) {
        V(R);
        V(S);
    }
    EntryY(R, S) {
        P(R);
        P(S);
    }
  • c)
    ExitX(R, S) {
       P(S);
       V(R);
    }
    EntryY(R, S) {
       V(S);
       P(R);
    }
  • d)
    ExitX(R, S) {
        V(R);
        P(S);
    }
    EntryY(R, S) {
        V(S);
        P(R);
    }
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
A certain computation generates two arrays a and b such that a[i]=f(i)...
The purpose here is neither the deadlock should occur nor the binary semaphores be assigned value greater 
than one.
A leads to deadlock
B can increase value of semaphores b/w 1 to n
D may increase the value of semaphore R and S to  2 in some cases
View all questions of this test
Most Upvoted Answer
A certain computation generates two arrays a and b such that a[i]=f(i)...
Free Test
Community Answer
A certain computation generates two arrays a and b such that a[i]=f(i)...
Explanation:

ExitX(R, S):
- In process X, the semaphore R is used to ensure mutual exclusion between processes X and Y.
- To exit process X, the semaphore S needs to be incremented to allow process Y to proceed.
- Therefore, the correct implementation for ExitX is to perform P(S) followed by V(R) to release the semaphore R and signal the process Y.

EntryY(R, S):
- In process Y, the semaphore S is used to ensure synchronization with process X.
- To enter process Y, the semaphore R needs to be decremented to wait for process X to finish.
- Therefore, the correct implementation for EntryY is to perform V(S) followed by P(R) to wait for the signal from process X before proceeding.
Therefore, the correct implementation of ExitX and EntryY is given by option 'C':
ExitX(R, S) { P(S); V(R); }
EntryY(R, S) { V(S); P(R); }
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer?
Question Description
A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 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 certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer?.
Solutions for A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. 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 certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer?, a detailed solution for A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.Process X: Process Y:private i; private i;for (i=0; i < n; i++) { for (i=0; i < n; i++) { a[i] = f(i); EntryY(R, S); ExitX(R, S); b[i]=g(a[i]);} }Q.Which one of the following represents the CORRECT implementations of ExitX and EntryY?a)ExitX(R, S) { P(R); V(S);}EntryY (R, S) { P(S); V(R);}b)ExitX(R, S) { V(R); V(S);}EntryY(R, S) { P(R); P(S);}c)ExitX(R, S) { P(S); V(R);}EntryY(R, S) { V(S); P(R);}d)ExitX(R, S) { V(R); P(S);}EntryY(R, S) { V(S); P(R);}Correct answer is option 'C'. 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