process sync - can it be portable?

William E. Davidsen Jr davidsen at steinmetz.ge.com
Fri Jan 20 03:30:41 AEST 1989


I have a program which will eventually run a number of copies all
sharing a number of files. My problem comes with locking... I want this
to run on as many types of system as possible, without excessive #if's.
I need to do a little access syncing with the following requirements:
	1) lock with wait - if already locked pause until free
	2) self unlocking if the process with the lock dies.

Now before I get 20 messages telling me what I already know, YES I can
do it on BSD, on SysV, Xenix, Ultrix, and SunOS. What I want is a single
portable method which will work from the same source code in each. In
the past I've used semiphores, simple locks, fancy locks (just parts of
a file), etc, messages, pipes, and shared memory for IPC. The problem is
that I want this to be portable.

Anyone got a good idea. Note that preserving order on multiple waiting
processes is not required. Long before locks become a bottleneck on this
program the system will run out of something else.

I will summarize mail, but would prefer to have replies posted to
simulate other ideas. I'll even take help from one of the "any fool
plainly knows that..." types at this point.
-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.unix.questions mailing list