in Databases edited by
676 views
9 votes
9 votes

Consider the following lock requests in the Table below. And note that:

  • $\mathrm{S}(\cdot)$ and $\mathrm{X}(\cdot)$ stand for 'shared lock' and 'exclusive lock', respectively.
  • $T_1, T_2, T_3, T_4$, and $T_5$ represent five transactions.
  • $L M$ represents a 'lock manager'.
  • Transactions will never release a granted lock.

$$
\begin{array}{|l||c|c|c|c|c|c|c|c|}
\hline \text{time} & t_1 & t_2 & t_3 & t_4 & t_5 & t_6 & t_7 & t_8 \\
\hline \hline T_1 & \mathrm{~S}(\mathrm{~A}) & & \mathrm{S}(\mathrm{B}) & & & & & \\
\hline T_2 & & \mathrm{X}(\mathrm{B}) & & & & & & \mathrm{X}(\mathrm{D}) \\
\hline T_3 & & & & \mathrm{~S}(\mathrm{C}) & \mathrm{X}(\mathrm{D}) & & \mathrm{X}(\mathrm{A}) & \\
\hline T_4 & & & & & & \mathrm{X}(\mathrm{C}) & & \\
\hline \hline L M & \mathrm{~g} & \mathrm{~g} & & & & & & \\
\hline
\end{array}
$$
To prevent deadlock, we use the lock manager $(L M)$ that adopts the Wound-Wait policy. We assume that in terms of priority: $T_1>T_2>T_3>T_4$. Here, $T_1>T_2 \text { because }\;T_1$ is older than $T_2$ (i.e., older transactions have higher priority). Determine whether the lock request is granted ('g'), blocked (' $b$ '), aborted ('a'), or already dead('-').

Select all that are correct.

  1. At t3: a
  2. At t6: b
  3. At t7: a
  4. At t8: -
in Databases edited by
676 views

4 Comments

Never release means it does not release until the program is over if everything gets right. It is not like that after t4 , transaction T1 work is over and it now releases the resourse
0
0

@krishnajsw, As @nishantsharma 's comment has explained.

Note that "transaction will never release a granted lock" means that transaction, by its own choice, will not release a lock that it has acquired. But the Lock Manager can abort a transaction & give its acquired resources to some other transaction. Also, "transaction will never release a granted lock" means that when a transaction is waiting for some new resource/lock, then it does not release already acquired resources/locks. 

0
0

@Deepak Poonia sir .. thanks got it

0
0

1 Answer

7 votes
7 votes

Learn Wound-Wait & Wait-Die schemes for Deadlock Handling here: https://youtu.be/FzhbOG40ZH8 

For wound-wait deadlock prevention scheme:

  • At t3: g
  • At t4: g
  • At t5: g
  • At t6: b
  • At t7: b
  • At t8: -

For wait-die deadlock prevention scheme:

  • At t3: b
  • At t4: g
  • At t5: g
  • At t6: a
  • At t7: a
  • At t8: g

Watch this: https://youtu.be/FzhbOG40ZH8 


Explanation for time $t_3:$

At time $t_3,$ the request is being made by transaction $T_1$, not be $T_2.$ Request by $T_1$ goes to Lock Manager (LM), which aborts $T_2$ and grants request of $T_1.$ So, at $t_3, $ the request that is made, is granted. 

Note that for each "request" we need to determine whether that request is granted or not. The transaction making that request is aborted or not, blocked or not.

Note that: Block == Wait ; So, blocked state == waiting state. Blocked & Abort are different.  

edited by

3 Comments

good question @Deepak Poonia Sir.. 

1
1

@GO Classes , @Deepak Poonia Sir , why t8 is '-' as Older process demanding from younger process so it should be granted na ?

0
0
No because at t3, the process T2 got aborted by T1 for acquiring lock on B.

So now entire T2 process is Aborted ,ie already dead.

I hope this is helpful :)
6
6