begin quoting Darren New as of Mon, Apr 30, 2007 at 09:40:29AM -0700: > Stewart Stremler wrote: > >>You can actually do locking between asynchronous processes without any > >>atomic instructions. > > >You need a test-and-set or equivalent. > > No, you actually don't. I thought you did, but you don't. As long as I > can read memory you've written to and eventually see it, it works. > > The basic technique is to allocate a semi-private memory cell to each > process, and a shared one to say whose turn it is. When someone is (say) > ready for a timeslice, they set their own cell to "I'm ready." Then > whoever's turn it is is responsible to find someone who is ready and set > the shared cell to point to that process before they sleep.
A sort of cooperative token-ring? Hm. Interesting. It falls over if there's nobody waiting for that memory. The process that has it can't give it to anyone, as there's no-one who wants the access. Whoops. This can be fixed by introducing Yet Another Process that does nothing but manage access rights -- it checks the request memory cell, and if it finds one set, it picks one and sets the access memory cell to the appropriate identifier. (Basically, message sends!) If we make this an OS service, the MMU can be used to enforce read/write access to memory... > Essentially, you organize things so there's only one process that can > write to any given memory address at any given time, and the identity of > that process can't be changed by more than one process. It seems like it would be slow. And consume a lot of memory. On the other hand, it is likely to be more fair. And a tagged-memory scheme has some nice security features as well. > >>It depends. Does "atomic" block out all other execution? Or does it > >>block out only other "atomic" blocks, in which case lots of languages > >>have that and it's pretty much one of the older synchronization > >>primitives invented. > > > >The former. > > I think they call that an "interrupt disable". Which is not something you typically have access to in a HLL. -- Tag each cell, or just each page? Stewart Stremler -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
