Help understanding semaphores and producer/consumer problem
October 16, 2010 3:45 PM Subscribe
Help understanding semaphores and producer/consumer problem (more inside..)
posted by Raichle to Computers & Internet (29 answers total) 2 users marked this as a favorite
I'm having a really hard time trying to understand how to write a program to address the following problem:
Program is intended to address the producer/consumer problem by producing sequential integers and then consuming them by printing to the screen. Should run as an infinite loop and never deadlock.
Ultimately I have to create my own data type for a semaphore and syscalls for up() and down() but I thought the best way to start would be to first use existing syscalls. However, I can't find existing syscalls for up() and down() that will allow me to test this. Any suggestions? Also, do I need to fork of the calls to the producer and consumer functions so that they are both running at once? I'm having a hard time wrapping my head around this.
My very incomplete code