record locking question - pretty urgent
Kenneth Brody
kenbrody at spamcop.net
Mon Oct 7 08:32:37 PDT 2013
On 10/7/2013 11:09 AM, Fairlight wrote:
> I need to design a mechanism for something, and I need to know the answer
> to something about record locking as a result.
>
> Let's say you had 20 clerk processes all running concurrently. Let's also
> say they need exclusive access to a single record in a table.
>
> 1) You use a protected lookup, right?
>
> 2) If process #3 has the protected lookup, do the other processes gain the
> ability to grab that record instantly, if they're all waiting on the record
> lock?
>
> 3) As the next process grabs the locked record, is it -assured- that only
> -one- of those processes will grab the lock, forcing the rest to wait for
> the same condition, where the current process releases the locked record?
> Basically, is prevention of a race condition guaranteed?
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.
--
Kenneth Brody
More information about the Filepro-list
mailing list