Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Multiuser database

From: SunandaDH:aol at: 25-Mar-2006 17:18

> Paavo: > I have been quite happy with semaphores.
Sunanda:
> It'd be worth checking the source of the semaphore handler you are using.
Paavo sent me the source of the functions he'd been using. They'd come originally from Brett's obtain-semaphore and release-semaphore: http://www.codeconscious.com/rebol/rebol-net.html Brett's come up with a neater idea than trying to open a file for update to obtain an exclusive lock. He's flipping a file between two names. That should result in an atomic operation on pretty much all platforms, so could be used as a fairly safe locking mechanism when all you have in common is access to a shared folder. It has problems as noted earlier in this thread -- if the task that applies the lock dies, then all future tasks are blocked. It also requires some sort of single-threaded start-up to create the file in the unlocked state; and if that start-up process is accidentally run again, it could accidentally release a lock. Those problems are fixable at the cost of a greatly complicated lock protocol. As Gabriele has said, this stuff isn't easy. Or at least, it isn't easy if you are trying to do it from outside of a privileged kernel state. Sunanda.