I am trying to control the movement of a graphics image across the screen, and was hoping of some advice on the matter.
As the image crosses the bridge, I use the first line in bold to increase the semaphores value by one, and when the image leaves the bridge, I use the second line in bold to decrease the semaphores value by one.
display_string("Train 1 arrived at Bridge\n",2);
display_string("Train 1 left the Bridge\n",2);
Currently this is my only use of the semaphore, but when i run the code I recieve the following error:
I am trying to limit the number of images on the bridge to 2, and I understood that semaphores can hold a value of > than 1, so am confused why it is saying the semaphore was already at it's maximum value.
train 1 thread failed in signal semaphore (onbridge sem)
tried to increment semaphore that already was at it's maximum value.
I wanted to solve the problem by reading the semaphores value, if IF > 2, stop other images from crosing the bridge.
If anyone can offer some advice on this, I would be most greateful.