Re: strategy for "robust" I/O operations

From: Daniel Kabs (
Date: 01/26/05

Date: Wed, 26 Jan 2005 10:00:49 +0100

Hello Ed,

thanks for being involved!

Ed Prochak wrote:
> I agree that the child thread would be useless without its parent.
> After some thinught on this, I believe it comes done to the design,
> specifically the protocol between the parent and child thread/process
> and between the child and the media. Once the protocol is defined you
> can decide whether it can be implemented as lightweight threads or
> needs heavy processes.

I concur. The problem boils down to the "communication protocol" used. Thus
I have to answer two questions: What messages to transfer and how to
implement the message passing.

You already suggested some messages.

Now to the second part of the problem: implementation
The protocol between the child and the media are the basic IO functions
provided by the operating system.
The protocol between parent and child is some sort of IPC. To realize it,
these possibilites spring to my mind:
- passing data through sockets using read()/write()
- using system V message queues msgsnd()/msgrcv()
- using shared memory (mmap() or shmat())

If we use *sockets*, the message dispatcher has to do select() to check for
new messages. For *message queues* a signal handler has to be used to
announce, that a new message has been queued. The same is true for *shared
memory*, I think. Finally, in Linux there is O_ASYNC for open().

If I proceed this way, I'll have to create an asynchronous message passing
framework that the "robust" IO layer can use for managing the requests and
responses between parent and child. Isn't there anything easier? :-)