Let's suppose there are N processes and we have the following code:
atomic <int> c = 0;
semaphore b = 0;
proc P(i){
...
if(c.getAndInc() < N - 1){
b.wait();
}
else{
b.signal();
}
...
}
A deadlock will occur as N - 2 processes will be blocked by $ b.wait() $. I'm trying to identify how the Circular wait condition holds, being a necessary condition as it is.
(Circular wait means that "A set $\{ P_0, P_1, ..., P_n \}$ of waiting processes must exist such that $P_0$ is waiting for a resource held by $P_1$, $P_1$ is waiting for a resource held by $P_2$, ..., $P_{n-1}$ is waiting for a resource held by $P_n$, and $P_n$ is waiting for a resource held by $P_0$". This quote is from the book "Operating System Concepts", by Silberschatz, Galvin and Gagne.)
In other words, as there is deadlock, the circular wait condition must hold, but I just don't see it. Is there anything I am misunderstanding?
Thanks!