examples of producer-consumer models?

  • Follow


Hi all.

I have three programs I need to write to interact with one another via
shared memory. Shared memory portions of the code are written and
working just fine for allocating the shared memory and mapping a
structure over top to access portions of that memory for data
movement.

Where I'm stuck is signaling these processes from one another to wake
them up to know when to act on the signals to move the data around.

The first process (A) needs to pass data to process (B) which then
needs to wait for a signal from process (C) to pass the data from (B)
to (C). As soon as (A) gets data, it needs to signal (B) so (B) can
buffer everything, but (B) needs to wait for a signal from (C) before
sending any of that data to (C).

Hope that makes sense.

I'm at a loss for where to look for this kind of code. I haven't been
around C for quite a few years, even longer for this sort of work, and
I'm pretty stumped. I'd appreciate any tips, links or example code.

Thanks much,
-id
0
Reply google 7/29/2004 6:46:34 PM

On Thu, 29 Jul 2004 11:46:34 -0700, ian douglas wrote:

> Hi all.
> 
> I have three programs I need to write to interact with one another via
> shared memory. Shared memory portions of the code are written and
> working just fine for allocating the shared memory and mapping a
> structure over top to access portions of that memory for data
> movement.
> 
> Where I'm stuck is signaling these processes from one another to wake
> them up to know when to act on the signals to move the data around.
Use sysv semaphores. (e.g. man semget). They are not the easiest
thing to be introduced to though. Unix Network Programming by R. Stevens
have some nice examples though, get the book.

0
Reply iso 7/29/2004 7:37:50 PM


1 Replies
511 Views

(page loaded in 0.048 seconds)

Similiar Articles:










7/23/2012 1:25:50 PM


Reply: