Reputation: 445
My research on that topic suggests that a semaphore won't allow some process to enter in another process's critical section. There might be some case, though, where this should be possible, IMO.
Let's say there are two processes, P1 and P2. There are two resources, R1 and R2. P1 has acquired R1 and P2 has acquired R2. But P1 needs R2 to come out of its critical section and P2 needs R1 to do the same.
Is this a situation where a deadlock may occur?
Upvotes: 1
Views: 1427
Reputation: 1822
No semaphore does not always prevent deadlocks. check link for details
https://courses.engr.illinois.edu/ece390/books/artofasm/CH19/CH19-15.html
yes two processes waiting for each other to release resources or already graped/acquired semaphore is a typical example of deadlock. Further details in above link are very relevant to your confusion
Upvotes: 2