Re: pipes
- From: CptDondo <yan@xxxxxxxxxxxxxxxx>
- Date: Wed, 29 Aug 2007 09:04:32 -0700
Alex Colvin wrote:
It's quite possible that this app might be dumping data into the pipe for days without anyone reading it.
The data is realtime; once it's read it has no time value at all, so I really don't care if it goes into a bit bucket.
This has been called the update/display problem -- you have a process that
updates (writes) the current state, and a process that displays (reads) the current state. In the simplest case, all you need is the single most
recent state. You want to decouple thew update and display processes. A
pipe (or any sequential communication) requires that they run at the same
speed.
Shared memory is ideal for this kind of communication. The updater writes the latest status, the displayer reads it. You can optimize a little by signaling the displayer that there's new data, as long as signals don't get queued (RTOSs often have "event"s). You may also have to make the updates atomic, although by clever use of update counters you can just retry interrupted displaying.
Look up the use of mmap on files, and maybe flock.
Thanks for the great discussion, folks.
I thought about shared memory, but I've never used it before.
Reading the various shared memory HOWTOs got me a bit confused.
From what I gather, I'm better off using BSD mmap, rather than SysV IPC... Right?
And in essence, all I have to do on the server is something like:
fd = open(somefile,O_WRONLY);
mmap(some block, PROT_WRITE....,fd)
then write to fd and do a msync????
On the client,
fd = open(somefile,O_RDONLY);
mmap(some block, PROT_READ....,fd)
then read from fd...
Is that about it?
I can't find any examples for this sort of thing. I guess it's too simple. :-)
Thanks,
--Yan
.
- Follow-Ups:
- Re: pipes
- From: Rainer Weikusat
- Re: pipes
- References:
- pipes
- From: CptDondo
- pipes
- Prev by Date: putenv for AIX and ifdef for AIX
- Next by Date: Re: Portable time profiling function
- Previous by thread: Re: pipes
- Next by thread: Re: pipes
- Index(es):
Relevant Pages
|