Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Record locking
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Use of locks== Record locks need to be managed between the entities requesting the records such that no entity is given too much service via successive '''grants''', and no other entity is effectively locked out. The entities that request a lock can be either individual applications (programs) or an entire processor. The application or system should be designed such that any lock is held for the shortest time possible. Data reading, without editing facilities, does not require a lock, and reading locked records is usually permissible. Two main types of locks can be requested: ===Exclusive locks=== Exclusive locks are exclusively held by a single entity, usually for the purpose of writing to the record. If the locking schema was represented by a list, the '''holder list''' would contain only one entry. Since this type of lock effectively blocks any other entity that requires the lock from processing, care must be used to: *ensure the lock is held for the shortest time possible; *not hold the lock across system or function calls where the entity is no longer running on the processor β this can lead to deadlock; *ensure that if the entity is unexpectedly exited for any reason, the lock is freed. Non-holders of the lock (a.k.a. '''waiters''') can be held in a list that is serviced in a round-robin fashion, or in a [[FIFO (computing and electronics)|FIFO]] queue. This would ensure that any possible waiter would get equal chance to obtain the lock and not be locked out. To further speed up the process, if an entity has gone to sleep waiting for a lock, performance is improved if the entity is notified of the grant, instead of discovering it on some sort of system timeout driven wake-up. ===Shared locks=== Shared locks differ from exclusive locks in that the '''holder list''' can contain multiple entries. Shared locks allow all holders to read the contents of the record knowing that the record cannot be changed until after the lock has been released by all holders. Exclusive locks cannot be obtained when a record is already locked (exclusively or shared) by another entity. If lock requests for the same entity are queued, then once a shared lock is granted, any queued shared locks may also be granted. If an exclusive lock is found next on the queue, it must wait until all shared locks have been released. As with exclusive locks, these shared locks should be held for the least time possible.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)