Readers and Writers problem

Hello,
I have a problem making a simulation program for the readers and writers problem, I want to have 1 writer and "n" of readers and I need to be able to see what's going on by printing a text saying for example "Reader 1 is reading"...etc

the problem is that I don't know how to make it that if writer comes first or the readers come first to do the "writing/reading data" and checks the semaphores after each time the function runs.
Thanks in advance.
Topic archived. No new replies allowed.