If you are not familiar with the problem, this is something like this .
I did not come to ask for an answer, I really finished all my coding. I just found that my solution does not solve it in the best way, because my solution allows only one car at a time on the bridge. I was hoping I could get some tips on how to use sem_wait and sem_post to solve this problem. I hope that the flow going in one direction will flow together, and not one at a time.
My solution currently looks something like this:
(default sem_t north and south = 1 to unlock for 1 car)
IF northcar, then sem_wait (south), sem_wait (north). Cross the bridge and then sem_post (north), sem_post (south). This is obviously wrong because it blocks the bridge from all cars except whatβs on it. I want to enable traffic flow. Any ideas?
I use randomly generated traffic, which adds a bit of complexity to it.
user427390
source
share