Saturday, September 6, 2025
HomeData Modelling & AIAlgorithms Quiz | Sudo Placement : Set 1 | Question 8

Algorithms Quiz | Sudo Placement : Set 1 | Question 8

Here are the two concurrent process P1, P2 with respective codes:
P1 code:

while (true) // infinite condition
{
A :____;
printf("%d", 1);
printf("%d", 1);
B:____;
}

P2 code:

while (true) // infinite condition
{
C:____;
printf("%d", 0);
printf("%d", 0);
D:____;
}

What should be the binary semaphore operation on A,B,C,D respectively and what must be the initial values of semaphore M,N inorder to get the output 110011001100….?
Where P is down and V is up operation respectively.
(A) A = P(N), B = V(M), C = P(M), D = V(N); M = 0, N = 1;
(B) A = P(N), B = V(M), C = P(M), D = P(N); M = N = 1;
(C) A = P(N), B = V(N), C = P(M), D = V(M); M = 1, N = 0;
(D) A = P(N), B = V(N), C = P(M), D = V(M); M = N = 1;

Answer: (A)
Explanation:
Quiz of this Question

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32270 POSTS0 COMMENTS
Milvus
82 POSTS0 COMMENTS
Nango Kala
6639 POSTS0 COMMENTS
Nicole Veronica
11803 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11869 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7029 POSTS0 COMMENTS
Thapelo Manthata
6704 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS