fork, vfork, shared mem, et al...

From: Tel Janin Aellinsar (icarus@loomis.berkshire.net)
Date: 12/20/95


I apologize for actually using this mailing list for its intended
purpose, but you'll just have to deal with it. ;p

I've been sort of thinking about how to go about rewriting Circle for a 
fork/vfork/etc style of input and output.  It would be a MAJOR rewrite, 
of course...  or at least a big one.  However, since this would be my 
first experience with real official multitasking, it shouldn't hurt me to 
think about it a little (in the event that I need to use it at a later 
date, or ever get around to doing that rewrite).

I've come up with a couple of different problems, or at least dizzyingly 
complex solutions to said problems.  I was sort of thinking that the 
parent process would do the listening (though I don't think it's 
necessary, provided only one of the children listens at a time).  When it 
received a connection, it would really fast do the accepting and so on, 
then fork (or vfork) a child process, giving it control of the connected 
socket from there on.  The pid and socket would be duplicated in a 
structure so that the parent process could kill all the children on its 
death (this sounds really nasty) and manage inter-process 
communications.  However, my problem is how to manage inter-process 
communications.

I would assume that I need some kind of shared memory, unless I want to 
use a file, which is a little risky (and slower besides).  So, how would 
I do that?  Assume that child 1 writes a request for a list of who's 
online to the shared memory.  The parent catches the request, then 
dispatches its own request to the shared memory pool.  Each of the 
children check occasionally and when they do write their information to 
the pool.  The glaring problem is that the first child to write to the 
pool will overwrite the request and the other children will be oblivious 
to the fact that a request was ever made;  meanwhile, the parent hangs, 
waiting endlessly for the answers from the other processes, and the 
requesting process hangs as well, waiting for an answer from the parent.

Any suggestions?  Ideally, I'd like to keep files out of it (as much as 
files can be kept out of any program that runs on a UNIX computer) and 
rely solely on memory.  How much work would it be to get a fancy message 
queueing system running?  To hell with a fancy one, any queueing system 
that works is fine with me.

Actually...  this IS sort of the incorrect message for the mailing list, 
but hey.  It's better than flames back and forth.

___________________________________________________________________________
icarus@Crocker.COM                           http://www.crocker.com/~icarus
Berserker Dragon -=={UDIC}==-              Ultima Dragons, Internet Chapter
Lord Eric P. McCoy IV                                 Knights of the Cosmos
***************************************************************************



This archive was generated by hypermail 2b30 : 12/07/00 PST