Unix Programming - fastest IPC?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > August 2005 > fastest IPC?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author fastest IPC?
rahul8143@gmail.com

2005-08-22, 5:59 pm

hello,
which is fastest IPC among semaphore,message queue,pipes,shared
memory and why?
regards,
rahul

Philippe Amarenco

2005-08-22, 5:59 pm

rahul8143@gmail.com writes:

> hello,
> which is fastest IPC among semaphore,message queue,pipes,shared
> memory and why?


shared memory is faster because the data is not copied from one
address space to another, memory allocation is done only once, and
syncronisation is up to the processes sharing the memory.

mostly, shared memory just give more control but if you use your
shared memory like a pipe, it probably won't make much difference
depending on your kernel implementation.


if you need a two-way communication, you can also consider using unix
domain sockets.

--
Philippe Amarenco, aka Phix
epita 2007 - LSE - EpX
"if new true friend not protected for explicit private union, break
case and try using this." -- Nathan Myers, longest c++ sentence.
Eric Sosman

2005-08-22, 5:59 pm



rahul8143@gmail.com wrote:
> hello,
> which is fastest IPC among semaphore,message queue,pipes,shared
> memory and why?


Which is the fastest among Opteron, cheetah, fortified
stronghold, and why?

Each of these is "fast" in some sense of the word, so
my question is unanswerable until I reveal which sense I am
asking about. Likewise, your question is unanswerable until
you reveal what you mean by "fast" (latency, throughput, other?)
and something about the circumstances (how much data, how
often, how many processes?).

Until then: "The fastest I/O is the one you don't do."

--
Eric.Sosman@sun.com

rahul8143@gmail.com

2005-08-23, 7:54 am


Eric Sosman wrote:
> rahul8143@gmail.com wrote:
>
> Which is the fastest among Opteron, cheetah, fortified
> stronghold, and why?
>
> Each of these is "fast" in some sense of the word, so
> my question is unanswerable until I reveal which sense I am
> asking about. Likewise, your question is unanswerable until
> you reveal what you mean by "fast" (latency, throughput, other?)
> and something about the circumstances (how much data, how
> often, how many processes?).
>
> Until then: "The fastest I/O is the one you don't do."
>
> --
> Eric.Sosman@sun.com


sorry i forget to mention that i want to know fast IPC method to
use in terms of max throughput lower time to access other process data.

Ulrich Hobelmann

2005-08-23, 7:54 am

rahul8143@gmail.com wrote:
> sorry i forget to mention that i want to know fast IPC method to
> use in terms of max throughput lower time to access other process data.


Well, since shared memory is a bad hack (IMHO) it would be good style to
use sockets and see if it's fast enough. That way you can even let your
process run on different internet machines (though with reduced speed)
if you need to.

See the man pages for socketpair, socket, bind ...

Do you want to use processes or pthreads? In the latter case you can
easily communicate with conditions, but some people also consider
threads a bad hack. ;)

--
I believe in Karma. That means I can do bad things to people
all day long and I assume they deserve it.
Dogbert
Nils O. Selåsdal

2005-08-23, 7:54 am

Philippe Amarenco wrote:
> rahul8143@gmail.com writes:
>
>
>
>
> shared memory is faster because the data is not copied from one
> address space to another, memory allocation is done only once, and
> syncronisation is up to the processes sharing the memory.
>
> mostly, shared memory just give more control but if you use your
> shared memory like a pipe, it probably won't make much difference
> depending on your kernel implementation.

Without a locking mechanism, good luck.
You need to incorporate your choice of locking when using
shared memory, sysv semaphores is often used.
Wether they will be faster than the implicit locking of
e.g. a pipe, and depening on your scheme for what/when to
lock/release - "faster" kind of depends on a lot of things.



--
Nils O. Selåsdal
www.utelsystems.com
Eric Sosman

2005-08-23, 5:56 pm



rahul8143@gmail.com wrote:
> Eric Sosman wrote:
>
>
>
> sorry i forget to mention that i want to know fast IPC method to
> use in terms of max throughput lower time to access other process data.


Maximum throughput: shared memory, in the biggest chunk
your system can provide without paging.

Be warned that my answer is no more useful than your
question is meaningful -- to wit, not very.

--
Eric.Sosman@sun.com

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com