Concurrency and Synchronization MCQ Quiz - Objective Question with Answer for Concurrency and Synchronization - Download Free PDF
Last updated on Jun 27, 2025
Latest Concurrency and Synchronization MCQ Objective Questions
Concurrency and Synchronization Question 1:
Mutual exclusion problem occurs
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 1 Detailed Solution
Concept:
Mutual exclusion happens when two or more processes share the same resources but can not access the same resource at the same time.
Explanation:
Mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions.
It is the requirement that one thread of execution never enters its critical section at the same time that another concurrent thread of execution enters its own critical section. This problem is resolved using different tools, e.g. semaphores.
Concurrency and Synchronization Question 2:
Which of the following is NOT a synchronization mechanism?
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 2 Detailed Solution
The correct answer is Racer.
- A racer is not a synchronization mechanism.
- Synchronization mechanisms are tools or constructs used to manage concurrent access to shared resources in programming.
- Common synchronization mechanisms include:
- Critical Section: A part of the code that accesses shared resources and needs to be executed by only one thread at a time.
- Semaphore: A signaling mechanism used to control access to shared resources by multiple threads.
- Mutex: A mutual exclusion object that ensures only one thread can access a resource at a time.
- On the other hand, racer refers to a race condition, which is a programming issue caused by improper synchronization, rather than a mechanism for achieving synchronization.
- Race conditions: Occur when multiple threads or processes compete to modify or access shared resources, leading to unpredictable behavior.
- Synchronization mechanisms are used to prevent race conditions in concurrent programming.
- Examples of programming languages with built-in synchronization mechanisms include Java, C++, and Python.
- Proper use of synchronization mechanisms ensures data integrity and prevents deadlocks in multithreaded applications.
Concurrency and Synchronization Question 3:
Which of the following are popular models of concurrent programming?
(a) Shared memory
(b) Branch and bound
(c) Message passing
(d) Event-driven
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 3 Detailed Solution
The correct answer is Option 4) (a) and (c) only.
Key Points
- There are two primary models of concurrent programming:
- Shared Memory Model: Multiple processes/threads communicate by reading and writing to shared variables or memory regions.
- Message Passing Model: Processes communicate by sending and receiving messages, useful in distributed systems where memory isn't shared.
- These models form the core of designing concurrent or parallel programs across systems and architectures.
Additional Information
- (b) Branch and Bound: ❌ It is an algorithm design paradigm for optimization problems, not a concurrency model.
- (d) Event-driven: ❌ It is a design paradigm based on responding to events (like GUI or asynchronous I/O), and not specifically a concurrency model.
Conclusion: (a) Shared Memory and (c) Message Passing are the correct and popular models for concurrent programming.
Concurrency and Synchronization Question 4:
Semaphores are used to solve the problem of:
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 4 Detailed Solution
The correct answer is both (1) and (2).
Key Points
- Semaphores are a synchronization mechanism used to control access to a common resource in a concurrent system such as a multitasking operating system.
- They are primarily used to solve the problems of mutual exclusion and process synchronization.
- Mutual exclusion ensures that only one process can access the critical section of code at a time, preventing race conditions.
- Process synchronization ensures that processes or threads are properly synchronized to avoid issues like deadlocks and ensure correct sequence of execution.
Concurrency and Synchronization Question 5:
What is the exact location of operating system in the memory?
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 5 Detailed Solution
The correct answer is Either low or high memory (depending on the location of interrupt vector).
- The operating system can reside in either low or high memory depending on the system architecture and the location of the interrupt vector table.
- The interrupt vector table is a special array that holds the addresses of the interrupt service routines.
- In some systems, the interrupt vector table is located at the beginning of memory, and in others, it is located at the end of memory.
Top Concurrency and Synchronization MCQ Objective Questions
The hardware implementation which provides mutual exclusion is
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 6 Detailed Solution
Download Solution PDFConcept:
TestAndSet is a hardware solution to the synchronization problem.
- In TestAndSet, we have a shared lock variable which can take either of the two values, 0 or 1.
→ 0 for Unlock
→ 1 for Lock
- Before entering into the critical section, a process enquires about the lock.
→ If it is locked, it keeps on waiting till it becomes free
→ if it is not locked, it takes the lock and executes the
critical section.
Conclusion:
In TestAndSet,
- Mutual exclusion and progress are preserved
- Bounded waiting cannot be preserved.
Important Point:
Semaphores are the software implementation of the same.
- It needs kernel level support to ensure that P and V operations remain atomic, but hardware support isn't essential.
- Both P & V operations must be indivisible and this is a mandatory condition.
Which of the following interprocess communication model is used to exchange messages among co-operative processes?
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 7 Detailed Solution
Download Solution PDFConcept:
Inter process communication (IPC) is a mechanism which allows processes to communicate with each other and synchronize their actions.
By maintaining this type of communication, processes are said to so-operate with each other. Processes can communicate with each other using these two ways:
- Shared Memory
- Message passing
To overcome difficulties in Readers-Writers problem, which of the following statement/s is/are true?
1) Writers are given exclusive access to shared objects
2) Readers are given exclusive access to shared objects
3) Both readers and writers are given exclusive access to shared objects.
Choose the correct answer from the code given below:
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 8 Detailed Solution
Download Solution PDFIn Readers-Writers problem, more than one Reader is allowed to read simultaneously but if a Writer is writing then no other writer or any reader can have simultaneous access to that shared object. So, Writers are given exclusive access to shared objects.
Hence option 1 is correct
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
P1 |
P2 |
P3 |
: : D = D + 20 : : |
: : D = D - 50 : : |
: : D = D + 10 : : |
The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y - X is __________.
Answer (Detailed Solution Below) 80
Concurrency and Synchronization Question 9 Detailed Solution
Download Solution PDFMaximum value (Y):
- Process P1 reads the initial value 100 during execution P1 will update the value of D to (100 + 20 = 120) and writes it to memory.
- P2 and P3 read the value 120 from the memory.
- P2 will get executed before P1 and write the value (120 - 50 = 70) to memory. Since P3 is holding D = 120 after its execution D will be equal to (120 + 10 = 130) ∴ Y = 130
Minimum value (X):
- P1, P2 and P3 read the value 100 from the memory
- P1 will execute first, after its execution it will update (D = 100 + 20 = 120)
- After P1, P3 will execute and it will update the value to (D = 100 + 10 = 110)
- Finally, P2 will be execute and D will be equal to 100 - 50 = 50 ∴ X = 50
- Y - X = 130 - 50 = 80
At a particular time of computation the value of a counting semaphore is 7. Then 20 P operations and 15 V operation were completed on this semaphore. The resulting value of the semaphore is
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 10 Detailed Solution
Download Solution PDFConcepts:
V(S): Signal operation will increment the semaphore variable, that is, S++.
P(S): Wait operation will decrement the semaphore variable., that is, S--.
Data:
Initial counting semaphore = I = 7
Wait operation = 20 P
Signal operation = 15 V
Final counting semaphore = F
Formula:
F = I + 15V + 20P
Calculation:
F = 7 + 15(+1) + 20(-1)
∴ F = 2
the resulting value of the semaphore is 2
Choose statements in context of monitor based synchronization scheme that use condition type variable x:
I: Only wait () and signal () operations can be involved on X.
II: If process p invokes X, wait() operation; then P is suspended until another process invokes X, signal().
III: The X, signal() operation resumes exactly one suspended process and if no process is suspended, the it has no effect.
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 11 Detailed Solution
Download Solution PDFThe monitor is one of the ways to achieve Process synchronization. The monitor is supported by programming languages to achieve mutual exclusion between processes.
- The operation x.wait(); means that the process invoking this operation is suspended until another process invokes x.signal();.
- The x.signal operation resumes exactly one suspended process. If no process is suspended, then the signal operation has no effect.
Wait operation
wait() : Process performing wait operation on any condition variable are suspended. The suspended processes are placed in block queue of that condition variable.
Signal operation
signal(): When a process performs signal operation on condition variable, one of the blocked processes is given chance.
Hence Option 4 is correct
Suppose P, Q and R are co-operating processes satisfying Mutual Exclusion condition. Then if the process Q is executing in its critical section then
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 12 Detailed Solution
Download Solution PDFConcepts:
A mutual exclusion (mutex) is a program object that prevents simultaneous access to a shared resource.
A critical section is a code segment that accesses shared variables and has to be executed as an atomic action. The critical section problem refers to the problem of how to ensure that at most one process is executing its critical section at a given time.
PROCESS:
ENTRY SECTION |
Process Q CRITICAL SECTION |
EXIT SECTION |
REMAINDER SECTION |
Since process ‘Q’ is in the critical section then other processes P and R cannot be in the critical section. Therefore neither ‘P’ nor ‘R’ executes in their critical section.
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0.
Process P0 |
Process P1 |
Process P2 |
While (true) { Wait (S0); Print ‘0’ Release (S1); Release (S2); } |
Wait (S1); Release (S0); |
Wait (S2); Release (S0); |
How many times will process P0 print ‘0’?
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 13 Detailed Solution
Download Solution PDFThe correct answer is option 1
Concept:
Binary semaphore which can take only two values 0 and 1 and ensure mutual exclusion.
A process is entered into the critical section only when the value of semaphore(s) = 1
Otherwise, it will wait until semaphore(s) >0
Explanation:
The semaphores are initialized as S0=1, S1=0, S2=0.
Because S0 =1 then P0 enter into the critical section and other processes will wait until either S1=1 or S2 =1
The minimum number of times 0 printed:
- S0 =1 then P0 enter into the critical section
- print '0'
- then release S1 and S2 means S1 =1 and s2 =1
- now either P1 or P2 can enter into the critical section
- if P1 enter into the critical section
- release S0
- then P2 enter into the critical section
- release S0
- P1 enter into the critical section
- print '0'
The minimum number of time 0 printed is twice when executing in this order (p0 -> p1 -> p2 -> p0)
The Maximum number of times 0 printed:
- S0 =1 then P0 enter into the critical section
- print '0'
- Then release S1 and S2 means S1 =1 and s2 =1
- Now either P1 or P2 can enter into the critical section
- If P1 enter into the critical section
- Release S0 means S0 =1
- S0 =1 then P0 enter into the critical section
- print '0'
- Then P2 enter into the critical section
- Release S0 means S0 =1
- S0 =1 then P0 enter into the critical section
- print '0'
Maximum no. of time 0 printed is thrice when execute in this order (p0 -> p1 -> p0 -> p2 -> p0)
So, At least twice will process P0 print ‘0’
Answer (Detailed Solution Below)
Concurrency and Synchronization Question 14 Detailed Solution
Download Solution PDFOperating Systems:
An operating system performs tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices.
Examples of operating systems are Window7, Window8, DOS, OS X, etc.
Some features of Windows Operating System -
- Supports GUI (Graphical user interface).
- Multitasking operating System (More than one task at the same time).
- Memory Management.
- Handling Input/Output etc.
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1 ( ) { |
P2 ( ) { |
C = B – 1; |
D = 2 * B; |
B = 2 * C; |
B = D – 1; |
} |
} |
The number of distinct values that B can possibly take after the execution is __________.
Answer (Detailed Solution Below) 3
Concurrency and Synchronization Question 15 Detailed Solution
Download Solution PDFInitial value of B is 2 /value stored in main memory
Value of B = 4
First execute P2()
P2 ( ) {
D = 2 * B; / 2 × 2 = 4
B = D – 1; / B = 4 – 1 = 3
}
write the value of B = 3 to memory
execute P1()
P1 ( ) {
C = B – 1; / C = 3 – 1 = 2
B = 2 * C; / B = 2 × 2 = 4
}
write the value of B = 4 is memory.
Distinct value of B is 4.
Value of B =3
First Execute P1()
P1 ( ) {
C = B – 1; / C = 2 – 1 = 1
B = 2 * C; / B = 2 × 1 =2
}
write the value of B = 2 to memory
then execute P2()
P2 ( ) {
D = 2 * B; / 2 × 2 = 4
B = D – 1; / B = 4 – 1 = 3
}
write the value of B = 3 to memory
One of the distinct values of B is 3.
Value of B = 2
First execute P2()
P2 ( ) {
D = 2 * B; / 2 × 2 = 4
B = D – 1; / B = 4 – 1 = 3
}
/don’t write to memory
execute P1() / with initial value of B = 2
P1 ( ) {
C = B – 1; / C = 2 – 1 = 1
B = 2 * C; / B = 2 × 1 = 2
}
write the value B = 3 by P2() in memory.
overwrite the value written by P2() as B = 2 by P1() in memory.
One of the distinct values of B is 2.
Therefore, the distinct values of B are 2, 3 and 4.
The number of distinct values that B can possibly take after the execution is 3.