Case 2 : Deadlocks in Databases
• Deadlock can occur if 2 processes access & lock records in database.
• 3 different levels of locking :
– entire database for duration of request
– a subsection of the database
– individual record until process is completed.
• If don’t use locks, can lead to a race condition.
Example:
1. P1 accesses R1 and locks it.
2. P2 accesses R2 and locks it.
3. P1 requests R2, which is locked by P2.
4. P2 requests R1, which is locked by P1.
No comments:
Post a Comment