record locking question - pretty urgent

Fairlight fairlite at fairlite.com
Mon Oct 7 09:57:56 PDT 2013


On Mon, Oct 07, 2013 at 11:32:37AM -0400, Kenneth Brody thus spoke:
> I assume what you are asking is:
> 
> When an exclusive resource(*) lock is removed, and there are
> multiple other processes already waiting to lock that same resource,
> is it guaranteed that exactly one of thoses processes will obtain
> the lock, and the rest continue to wait?
> 
> Yes, that's the way exclusive(**) locks work.
> 
> 
> (*) A "resource" can be a contiguous region of bytes within a file.
> 
> (**) There are also non-exclusive locks available.  For example,
> some systems allow "read locks" and "write locks".  There can be
> multiple "read locks" on a given resource, but a "write lock" is
> exclusive.

That is correct.  I wanted to make sure a race condition wouldn't let two
records think they grabbed the exclusive lock at the same time.

That said, the order in which they lock is -NOT- guaranteed to be FIFO, am
I correct?  It's totally dependent upon lock release time vs subsequent
lock attempt times, and affected by CPU timeslice skewing?

Further question:  The protected lookup is blocking by default, is it not?
Richard's example showed using LOCKED(), but he also had a -w flag on his
lookup, and I've never seen that flag before.  By default, protected
lookups just spin and wait for their turn at the resource trough, yes?

mark->
-- 
Audio panton, cogito singularis.


More information about the Filepro-list mailing list