9、
(1)
2、4、8、16
(2)
T1 | T2 | T3 |
---|---|---|
Slock A | ||
Y=R(A)=0 | ||
Unlock A | ||
Xlock A | ||
SlockA | ||
A=Y+2=2 | 等待 | |
W(A) | 等待 | |
Unlock A | 等待 | |
X=R(A)=2 | ||
Unlock A | ||
Xlock A | ||
SlockA | ||
A=X*2 | 等待 | |
W(A) | 等待 | |
UnlockA | 等待 | |
Z=R(A)=2 | ||
Unlock A | ||
Xlock A | ||
A=Z**2 | ||
W(A) | ||
UnlockA |
(3)
T1 | T2 | T3 |
---|---|---|
Slock A | ||
Y=R(A)=0 | ||
Sclock A | ||
UnlockA | 等待 | |
X=R(A)=0 | ||
UnlockA | ||
Xlock A | ||
A=Y+2=2 | ||
Slock A | ||
W(A) | 等待 | |
Unlock A | 等待 | |
Y=R(A)=2 | ||
Unlock A | ||
Xlock A | ||
A=Y**2 | ||
Xlock A | ||
等待 | W(A) | |
等待 | Unlock A | |
A=X*2 | ||
W(A) | ||
UnlockA |
(4)
T1 | T2 | T3 |
---|---|---|
Slock A | ||
X=R(A)=0 | ||
Xlock A | ||
A=A+2 | ||
Slock A | ||
W(A)=2 | 等待 | |
Unlock A | 等待 | |
Y=R(A)=2 | ||
XlockA | ||
UnlockA | 等待 | |
A=Y*2 | ||
SlockA | ||
W(A) | 等待 | |
Unlock A | 等待 | |
Y=R(A)=4 | ||
XlockA | ||
UnlockA | 等待 | |
A=Y**2 | ||
W(A) | ||
UnlockA | ||
UnlockA |
(5)
T1 | T2 | T3 |
---|---|---|
Slock A | ||
X=R(A)=0 | ||
Slock A | ||
X=R(A)=0 | ||
XlockA | ||
等待 | ||
XlockA | ||
等待 | ||
SlockA | ||
X=R(A)=0 | ||
XlockA | ||
等待 |
10、
把r1(A)与w3(B)r2(B)交换,得到
r3(B)w3(B)r2(B)r1(A)r2(A)w2(B)r1(B)w1(A)
再把r1(A)和r2(A)w2(B)交换,得到
r3(B)w3(B)r2(B)r2(A)w2(B)r1(A)r1(B)w1(A)
等价于一个串行调度T3、T2、T1,所以是冲突可串行化调度
14、
(1)
T1 | T2 |
---|---|
Slock A | |
X=R(A) | |
Y=R(B) | |
Xlock B | |
B=A+B | |
W(B) | |
Unlock A | Slock B |
Unlock B | 等待 |
X=R(B) | |
XlockA | |
Y=R(A) | |
A=A+B | |
W(A) | |
Unlock B | |
UnlockA |
(2)会引起死锁
T1 | T2 |
---|---|
Slock A | |
X=R(A) | |
Y=R(B) | |
Slock B | |
B=A+B | |
Slock B | |
X=R(B) | |
SlockA | |
Y=R(A) | |
A=A+B | |
Xlock B | |
等待 | XlockA |
等待 | 等待 |