codescracker


operating system os

OS Two-Phase Locking



« Previous Tutorial Next Tutorial »


In several database systems, an operation that occurs frequently is requesting locks on several records and then updating all the locked records.

There is a real danger of deadlock whenever multiple processes are running at the same instance of time.

The approach used is called as two-phase locking.

In first phase, the process tries to lock all the records that it needs, one at a time. And if it succeeds, then it begins the second phase, performing its updates and releasing the locks. No any real work is done in first phase.

If during the first phase, some record is needed that is already locked, the process just releases all its locks and starts the first phase all over.

In several versions of two-phase locking, there is no any release and restart if a lock is encountered during the first phase. Deadlock can occur in these versions.


« Previous Tutorial Next Tutorial »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test