producer-consumer woes [resolved]
Hi guys and gals,
I got myself into a bad situation. If I don't finish this producer consumer project by tomorrow there is a chance I won't get my undergrad degree (or I'll have to pay through the nose next fall to retake the class). Let me be clear: this is utterly my fault. I dicked around spring quarter and now I'm frantic.
It's an involved problem, so I'm willing to pay for help. I don't want it done for me, but I do want to go through it with someone who has experience implementing semaphores and managing shared memory.
The situation: there are three programs, source, filter, and display. Source produces "messages", places them in a buffer which filter then reads, processes, and puts into a second buffer which is then emptied by display (which displays them). But it's trickier than that because there are really 4 sources, 3 filters, and 3 displays (achieved using fork in each program).
If I take out the fork() calls and run only one process of each program, it works fine. But putting the fork() calls back in causes a seg fault *only* in the display process, and I cannot for the life of me figure out why (the code is nearly identical to what's going on between source and filter, so why it becomes a problem between filter and display is a mystery). The other two run programs normally until they can't do anything because the buffers aren't getting emptied and they just hang. It's almost there -- there's got to be some little logical step I'm missing.
(This is just a synopsis. Source code and more details will follow for serious responders.)
If there is anyone out there who is inclined to help me with this (and there are plenty of reasons not to be so inclined), I'm willing to pay them a standard hourly wage for a mid-level C programmer. (Hope this isn't against any rules.. If it is, sorry for wasting your time.)
I'll be fielding responses through the night and morning, but my deadline is Friday afternoon PST.
Cheers,
shoba