Re: pipes



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
.



Relevant Pages

  • Re: XP SP 1
    ... Plus I have been reading all the ... newsgroups comments on SP1 for xp and went to the XP SP ... >access to newer critical updates. ... >> I was reading about the XP SP update for windows and was ...
    (microsoft.public.windowsxp.security_admin)
  • Re: XP SP 1
    ... Plus I have been reading all the ... >>access to newer critical updates. ... >>> I was reading about the XP SP update for windows and was ... >>> reading all the horrible things people are experiencing ...
    (microsoft.public.windowsxp.security_admin)
  • sfc /scannow only runs to 12%
    ... I am not really that computer savy, but after reading several posts ... installing updates. ... updates was "windows update agent 7.2.6001.788" There after, ... After reading a lot here and there about the update issue, ...
    (microsoft.public.windows.vista.performance_maintenance)
  • Re: [4.11] sysctl reports garbage
    ... den 27.04.2005 schrieb Marc Olzheim um 20:10: ... >> I've updates my system this morning after reading about the usb mfc. ...
    (freebsd-stable)
  • Re: SQL JOB Write to a File
    ... Reading a file and doing ... Inserts and Updates to the Database? ...
    (microsoft.public.sqlserver.server)