Semaphores are used to
• (A) Synchronise critical resources to prevent deadlock
• (B) Synchronise critical resources to prevent contention
• (C) Do I/O
• (D) Facilitate memory management
- Semaphores are used to synchronize processes in a computer system. They are used to control access to shared resources and ensure that only one process can access the resource at a time.
- Semaphores can be used to prevent race conditions, where two or more processes try to access a shared resource simultaneously, which can lead to unexpected or incorrect results.
- Semaphores are often used in operating systems to control access to critical sections of code, shared memory, and other system resources.
- A deadlock is a situation in computer science where two or more processes or threads are unable to continue execution because they are waiting for resources that are held by another process or thread.
- This creates a circular dependency, where each process is waiting for the other to release the resource, resulting in a standstill.
- Deadlocks can occur in systems with limited resources, such as computer memory or shared locks, and can be difficult to detect and resolve.
- It is important to design systems to avoid deadlocks or to implement mechanisms to detect and resolve them if they do occur.
Semaphores are used to Synchronise critical resources to prevent deadlock