Producer-comsumer threads using semaphore mutex
Ive been programming for a little while and i need help!
I need to produce code so that a producer thread can generate an integer between 0 and 9, store it in a file and dispaly the number on the screen. After the generation the producer sleeps for a random amount of time between 0 and 100 miliseconds before reapeating the number generation.
The consumer thread being ravenous, consumes all integers from the file as quickly as the become available. The producer must have a way of indicating to the consumer that a value is ready and teh consumer must have a way of indicating that the value has been retrieved.
I need to use wait() and signal() functions and semaphore mutex but i really dont know how. I would really be grateful if anyone could tell me where i could get such code.