views:

723

answers:

5
  1. Which IPC among message queues, shared memory and semaphores is easiest to convert to network IPC and which is the hardest.

  2. Would it be easier to convert System V shared memory to network IPC or Posix shared memory to network IPC

+1  A: 
  1. I'd say message queues by far on the basis that the operations you perform on a message queue has almost identical mappings on to socket operations.
  2. Probably equally hard, I'd suggest you implement some slightly more network friendly abstraction on top of shm...such as a message queue. Shared memory not very suited for networking even though there are some network-enabled implementations of it, but the ones I've come across are leaky abstractions indeed.
Henrik Gustafsson
A: 

As Henrik Gustafsson said:

  1. Message queues are by far the easiest IPC mechanism to convert to network. Semaphores are not designed to convey data, and shared memory typically needs semaphore-controlled access (or an equivalent mechanism) to provide proper control even on a single machine, let alone across a network. That said, System V message queues are probably the least widely used IPC mechanism.

  2. The conversion of any shared memory mechanism is approximately equally hard. The key point to note is that in fact you seldom if ever use 'just shared memory'; there are other synchronizing tools in use too.

Jonathan Leffler
A: 

You know these projects ? maybe it helps :

D-Bus
Spread

lsalamon
A: 

(1). The easiest is message queues and the hardest is shared memory.

I think it is because message queues just require a pointer to the message queue data structure where as shared memory requires attaching the shared memory to the process address space of both the processes and allocating shared memory is difficult when the two processes are on different machines.

(2). It is easier to convert Posix shared memory than System V shared memory to network IPC.

I think it is because Posix supports both memory based and named semaphores and does not require kernel intervention whereas System V requires OS intervention.

Anonymous
A: 
  1. Semaphores are not really a communication mechanism, they are for synchronization. Shared memory can be used over a network (Distributed Shared Memory), but that is quite hard to implement. Message queues are easy because they map directly onto network sockets.

  2. It would probably be quite similar difficulty; both APIs are similar, they just have a different interface.

Zifre