GATE CS Concurrency and Synchronization questions
Practise Concurrency and Synchronization questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.
Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.
18 on this page
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows: void enter_CS(X) { while(test-and-set(X)); } void leave_CS(X) { X = 0; } In the above solution, is a memory location associated with the and is initialized to . Now consider the following statements: The …
The and operations on counting semaphores, where s is a counting semaphore, are defined as follows: If then wait; If then wake up process waiting on s; Assume that and the wait and signal operations on binary semaphores are provided. Two binary semaphores …
Two processes, and , need to access a critical section of code. Consider the following synchronization construct used by the processes: /* P1 */ while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1 = false; } /* Remainder section */ /* P2 */ while (true) { wants2 = true; while (wants1 == true); /* Critical Section …
Barrier is a synchronization construct where a set of processes synchronizes globally i.e., each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and be a binary semaphore with the usual and functions. Consider the following …
Barrier is a synchronization construct where a set of processes synchronizes globally i.e., each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and be a binary semaphore with the usual and functions. Consider the following …
The atomic fetch-and-set instruction unconditionally sets the memory location to and fetches the old value of in without allowing any intervening access to the memory location . Consider the following implementation of and functions on a binary semaphore . void P (binary_semaphore *s) { unsigned y; …
Consider two processes and accessing the shared variables and protected by two binary semaphores and respectively, both initialized to 1. and denote the usual semaphore operators, where decrements the semaphore value, and increments the semaphore value. The pseudo-code of and …
Suppose we want to synchronize two concurrent processes and using binary semaphores and . The code for the processes and is shown below. …
Suppose we want to synchronize two concurrent processes and using binary semaphores and . The code for the processes and is shown below. Process P: Process Q: while(1){ W: print '0'; print '0'; X: } while(1){ Y: print '1'; print '1'; Z: } Synchronization statements can be inserted only at points and Which …
Consider Peterson's algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below. repeat flag[i] = true; turn = j; while (P) do no-op; Enter critical section, perform actions, then exit critical section Flag[i] = false; Perform other non-critical section actions. Until false; For the program to …
Let be mutexes (binary semaphores) and be processes. Suppose each process executes the following: wait (m[i]); wait (m(i+1) mod 4]); ........... release (m[i]); release (m(i+1) mod 4]); This could cause
A counting semaphore was initialized to . Then (wait) operations and (signal) operations were completed on this semaphore. The resulting value of the semaphore is
When the result of a computation depends on the speed of the processes involved, there is said to be
Each Process is coded as follows repeat P(mutex) {Critical section} V(mutex) forever The code for is identical except it uses V(mutex) in place of P(mutex). What is the largest number of processes that can be inside the critical section at any moment?
A solution to the Dining Philosophers Problem which avoids deadlock is to
A critical section is a program segment
At a particular time of computation, the value of a counting semaphore is . Then operations and operations were completed on this semaphore. The resulting value of the semaphore is :
A critical region is
