Database Management Systems (2130703)

BE | Semester-3   Summer-2018 | 05/23/2018

Q4) (a)

Write differences between shared lock and exclusive lock.

Exclusive locks

Exclusive locks protect updates to file resources, both recoverable and non-recoverable. They can be owned by only one transaction at a time. Any transaction that requires an exclusive lock must wait if another task currently owns an exclusive lock or a shared lock against the requested resource.

Shared locks

Shared locks support read integrity. They ensure that a record is not in the process of being updated during a read-only request. Shared locks can also be used to prevent updates of a record between the time that a record is read and the next syncpoint.
A shared lock on a resource can be owned by several tasks at the same time. However, although several tasks can own shared locks, there are some circumstances in which tasks can be forced to wait for a lock:
  • A request for a shared lock must wait if another task currently owns an exclusive lock on the resource.
  • A request for an exclusive lock must wait if other tasks currently own shared locks on this resource.
  • A new request for a shared lock must wait if another task is waiting for an exclusive lock on a resource that already has a shared lock.