I've been trying for a few weeks now to figure-out how to implement this. I know it sounds lame but I really have read all I can and still baffled. It would be really cool if some can give me some clues or pointers...
From what I understand I have to use a mutex semaphore class to lock individual processes of a thread. To create inter-process-communication, a shared buffer is used to pass the results of the first errr..( producer. ) The results of the first process are parsed to a 'Shared Data Buffer' and processed by another class of instantiated objects ( the consumer ) The buffer is needed, as you know, to create a queue that waits for a free consumer object to process it.
I'm having trouble understanding how I pass threads exclusively to more than one instance of an object in-turn ?
I think the buffer will have a counter variable for the number of threads to expect. When the buffers counter is == 0 there's no-more threads to parse to consumer objects.
The scenario of the program, so that it may make more sense is as so:
The producer objects are maybe many study rooms. Students occupy each room that then becomes locked ( semaphore ) The room only becomes unlocked once the student choses a random number and that number has been recorded by the consumer via the Shared Buffer. Once a room becomes un-locked it is now free for the next sudent.
Can anyone kindly give me an example of how to implement the shared buffer ?? any help or constructive suggestion would be most welcome
cheeers M000 !!!!
-- not for biscuits -- we need answers.