Briefly explain the differences between a semaphore and a condition variable, and what problem in common these two synchronization primitives solve.
Answer)
The conditions variables are used for avoiding the cases for busy
waiting, when or more processes or threads are waiting for some
shared resources. This method provides access to the shared
resource and also for achieving mutual exclusion. Semaphores are
used also for maintaining and implementing the exclusive access tot
he variables and also resources. Semaphores are simply variables
which are used in the computing are being used to solve the
critical section problems and resources. While the condition
variables are the primitive which mean that the threads and
processes would have to wait till a particular condition has
occurred thereby preventing access to the resource, which can be
useful for controlling busy waiting. Thus these two synchronization
primitives for solving the problems related to threads accessing
the shared resources.
Get Answers For Free
Most questions answered within 1 hours.