Ask a Question related to UNIX Programming, Design and Development.
-
Richard #1
Is this IPC scheme brain-dead?
I'm designing an IPC scheme that I've never used before, and I need
to vet it. I don't have any local resources to run it by, and would
appreciate it if someone would point out if I'm about to do something
really stupid due to possible personal ignorance of mine.
I have three processes. Inputs to the process #1 consist of a steady
stream of data, maxing at about 8MB/sec but averaging not much lower.
The first process just tries to keep up with the input, and adds a
little metadata to it before sending it to process #2 via shared
memory. Process #1 queues this data for about 200 ms before sending
it, so that it sends a big block rather than a bunch of little
records. The block size will naturally vary from
Process #2 takes its inputs from shared memory and does some
filtering and restructing (summarizing) of the data before sending it
to process #3 via shared memory.
The (possibly) unusual part is that I want to use FIFOs between
processes to coordinate the update/read status of shared memory
segments. My initial idea was to logically structure the shared
memory as an array of fixed-length records, and use semaphores to
implement a record-locking scheme for updates and reads. (I can
provide more detail on this, but it's hopefully pretty obvious what I
had in mind.)
The problem with fixed-length records, of course, is sizing them
correctly to avoid wasting space--or spending a lot of time dealing
with the individual data records that are bigger than the fixed
record size and winding up with a lot of overhead to manage the
overflow mappings.
To get around this, I figured I could write large blocks of varying
size to shared memory--and just use a FIFO from proc #1 that gives
the OFFSET and BYTE_LEN of the data written to shared memory. Proc #
2 picks this up, reads the block of data, and then uses a FIFO back
to proc #1 with OFFSET and BYTE_LEN to advise proc #1 that it's read
that block.
The writer to shared memory would just write along the shared memory
size until it wrapped around back to the top. The FIFOs would be
used mainly to advise the shared memory writer that a given
OFFSET/BYTE_SIZE message had been received by the reader and the data
picked up.
I do a similar thing between procs #2 and #3.
Now, it doesn't work too well if the writer fills up shared memory
faster than the reader reads it, but that's true anyway no matter
what access scheme I use.
Anyway, like I've said, if this is a notoriously stupid idea that I
just haven't bumped into yet...would somebody mind pointing that out?
(I know I'm asking a lot to ask programmers to point out what's wrong
with some other programmer's approach... ;)
--
For email, put NOT SPAM in Subject or I'll probably miss it.
<><
# rm /bin/laden
# /bin/laden: Not found
Richard Guest
-
Vista sound scheme?
Is there an official sound scheme for Vista yet? Not really a big or important question, but I'm just curious. I've got a sound scheme right now... -
Backup scheme
Hi, I have a script that runs and zips a file, then copies it to another directory on another system. It also goes through and renames each file... -
authentication/login scheme
I am a developer, not an administrator and want to ask you guys for advice on designing a login/authentication scheme for a new .Net C# product. ... -
[PHP] Feeling a bit brain dead, please help in maths: averages
Hey, Thanks for replying. Actually I made that example simple, i actually need the average of 7 to 9 fields....and i dont want to run 7 selects... -
Feeling a bit brain dead, please help in maths: averages
Hey, Been working a bit too much i guess so am feeling braindead... I have a couple of records in the database, i am doing a: "select... -
Marc Rochkind #2
Re: Is this IPC scheme brain-dead?
On Sun, 27 Jul 2003 21:06:01 GMT, Richard <rh310@hotmail.com> wrote:
[snipped .. see original msg]> I'm designing an IPC scheme that I've never used before, and I need to
> vet it. I don't have any local resources to run it by, and would
> appreciate it if someone would point out if I'm about to do something
> really stupid due to possible personal ignorance of mine.
>
This sounds like a promising scheme to me. With shared memory, you always
need one other IPC mechanism for synchronization. Using FIFOs or messages
also allows you to include some data in the synchronization message, which
is what you are doing here.
Design the thing so that you can play with various sizing parameters to
discover what works best.
An alternative to FIFOs would be SysV or POSIX messages. They have some
advantages over FIFOs, in that they are inherently messages, whereas with
FIFOs you have to superimpose the message structures on the stream-oriented
FIFO.
Staying away from semaphores is a good idea -- avoids lots of complex
analysis to ensure that you are deadlock and starvation free.
--Marc>
Marc Rochkind Guest
-
Larry Blanchard #3
Re: Is this IPC scheme brain-dead?
In article <oprszt5rolojfyi9@den.news.speakeasy.net>,
[email]rochkind@basepath.com[/email] says...Back in the dim days of slow 486's, I sent, IIRC, at least 10,000 small> An alternative to FIFOs would be SysV or POSIX messages. They have some
> advantages over FIFOs, in that they are inherently messages, whereas with
> FIFOs you have to superimpose the message structures on the stream-oriented
> FIFO.
>
messages a second around a loop of 3 or 4 processes. It might be
interesting to see what the throughput would be with todays hardware.
You might not even need shared memory :-).
BTW, that was with SYSV IPC on SCO's Xenix. I did have to play with the
kernel message queue parameters.
--
Where ARE those Iraqi WMDs?
Larry Blanchard Guest
-
Marc Rochkind #4
Re: Is this IPC scheme brain-dead?
On Mon, 28 Jul 2003 09:48:39 -0700, Larry Blanchard <lblanch@fastmail.fm>
wrote:
[snip]
Depends on the message size. For example, for some tests I ran with> Back in the dim days of slow 486's, I sent, IIRC, at least 10,000 small>>
> messages a second around a loop of 3 or 4 processes. It might be
> interesting to see what the throughput would be with todays hardware.
> You might not even need shared memory :-).
>
> BTW, that was with SYSV IPC on SCO's Xenix. I did have to play with the
> kernel message queue parameters.
>
messages sizes of 100 bytes, 2000, 20000, and 100000,
the time to pass the data between processes using shared memory with
semaphores was flat -- around 1.3 units. Times for SysV messages were .9
for 100 byte messages and 1.82 for 2000 byte messages. The two larger sizes
were too big. For AF_UNIX sockets, times were 1.84, 2.15, 10.15, and 44.13.
(All times were normalized by running the test for FIFOs with 100-byte
messges and setting that time to 1.00.) I ran the test with Solaris, Linux,
FreeBSD, and Darwin (Mac OS X) with very similar results.
Conclusion: Shared memory is only valuable if (1) there is some reason why
the memory has to be shared, or (2) the message size is more than a few
hundred bytes.
--Marc
Marc Rochkind Guest
-
Richard #5
Re: Is this IPC scheme brain-dead?
[email]apm35@student.open.ac.uk[/email] wrote...
I'd be happy to. I guess I should make sure some leech doesn't have> Marc Rochkind <rochkind@basepath.com> wrote in message news:<oprszt5rolojfyi9@den.news.speakeasy.net>...>> > On Sun, 27 Jul 2003 21:06:01 GMT, Richard <rh310@hotmail.com> wrote:
> > This sounds like a promising scheme to me.
> Me too. Will you GPL it when it's finished?
a patent on it first. Thanks for the suggestion.
This is the first time I've used POSIX shared memory, and so far I've>> > With shared memory, you always
> > need one other IPC mechanism for synchronization. Using FIFOs or messages
> > also allows you to include some data in the synchronization message, which
> > is what you are doing here.
> I think that what he is after is actually a simulation of FIFOs but
> without the FIFO limiation that there is a relatively small maximum
> message size. Obviously, a msg cannot be larger than the shared memory
> file but FIFOs have a msg limit imposed by the kernel and IMO it is
> quite small. It can lead to queueing problems when there is latency.
>>> > An alternative to FIFOs would be SysV or POSIX messages.
> Please don't use SysV msg queues. See Stevens for why these are
> inferior (despite advantages such as builtin demultiplexing).
been very pleasantly surprised at how flexible and easy it is to use.
For some reason, I was expecting it to be more difficult than it
turned out to be--it took me a few hours just to even recognize its
simplicity.
I'd prefer to use messages over FIFOs, and will look that doing that
today. FIFOs are simple and it was easy to start there, but I do
have some concerns about the 4K limit, even though my "records" into
the FIFO are only 10 bytes each.
--
For email, put NOT SPAM in Subject or I'll probably miss it.
<><
Richard Guest



Reply With Quote

