If you're unfamiliar with the problem, it's something like this.
I didn't come to ask for an answer, I have actually finished all of my coding. I have just found that my solution doesn't solve it the best way possible, because my solution only allows one car at a time on the bridge. I was hoping I could get some tips about how to go about using sem_wait and sem_post to solving this problem. I hope to allow traffic flowing the same direction to flow together and not one at a time.
My solution currently looks something like:
(default sem_t north and south = 1 for unlocked 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's locking the bridge from all cars other than the one on it. I want to enable traffic to flow together. Any ideas?
I am using randomly generated traffic which adds a bit of complexity to it.