Semaphores
20072007
Semaphores
- A.
synchronize critical resources to prevent deadlock
- B.
synchronize critical resources to prevent contention
- C.
are used to do I/O
- D.
are used for memory management
Attempted by 301 students.
Show answer & explanation
Correct answer: B
Semaphores are synchronization primitives used in concurrent programming to manage access to shared resources among multiple processes or threads. Their primary purpose is to prevent race conditions, which occur when two or more processes try to access the same critical resource simultaneously without proper coordination. By using semaphore operations (wait and signal), processes can safely coordinate their access to shared resources, ensuring that only one process accesses the critical section at a time. This synchronization mechanism helps maintain data consistency and prevents conflicts in multi-threaded or multi-process environments.
A video solution is available for this question — log in and enroll to watch it.