102 高考三等 資料庫問題 - 高考
By George
at 2015-05-03T22:47
at 2015-05-03T22:47
Table of Contents
Tr1和Tr2是兩個交易,某次執行程序如下:假設x和y在硬碟的初始值為 x=1000 y=1000。
Time| Tr 1| Tr2
______________________
t1 | read X |
t2 | read Y
t3 | X=X-1000 |
t4 | | read X
t5 | write X |
t6 | | Y=Y+1000
t7 | | write Y
Q1 若兩交易以2PL執行,請問系統如何進行?
我的想法是用2PL的保守法,針對要用的資源先全部鎖定,用完後再一次釋放,故我先讓
Tr2先使用資源並全數鎖定X、Y,解鎖後再讓Tr1使用資源
Tr1 Tr2
-- -------------------------------
鎖定期 Luck_read(y)
Luck_read(X)
Luck_write(Y)
read Y
------------------------------------
解鎖期 Y=X+1000
Unluck_write(Y)
write Y
Unluck_read(Y)
Unluck_read(X)
------------------------------------
鎖定期 Luck_read(X)
Luck_write(X)
------------------------------------
X=X-1000
解鎖期
write X
Unluck_write(X)
Unluck_read(X)
請問可否這樣解?
Q2.若使用time-stamp執行,且Tr在Tr2之後才進來,說明執行結果
設 Tr1 起始時間200 Tr1起始時間100
且分別設定write/read的起始時間分別為 W_max=90 R_max=90
Time| Tr1 | Tr2
______________________
t1 | read X | // Tr1(200)>= R_max(90) , R_max=200
t2 | read Y //Tr2(100)<=R_max(200) , Tr2重跑 得到新的時間300
t3 | X=X-1000 |
t4 | | read X // Tr2(300)>=R_max(200) , R_max=300
t5 | write X | //Tr1(200)< R_max(300) ,Tr1(200)> W_max(90),但 Tr1仍
//需重跑 得到新的時間400
t6 | | Y=Y+1000
t7 | | write Y //Tr2(300)>=R_max(200) 且 Tr2(300)>W_max(90)
但參考了高點的解答,為何說該兩交易之排成可順利完成
請版上高手綁我檢視我的想法有沒有問題?或有那裡考慮的不周全?
--
Time| Tr 1| Tr2
______________________
t1 | read X |
t2 | read Y
t3 | X=X-1000 |
t4 | | read X
t5 | write X |
t6 | | Y=Y+1000
t7 | | write Y
Q1 若兩交易以2PL執行,請問系統如何進行?
我的想法是用2PL的保守法,針對要用的資源先全部鎖定,用完後再一次釋放,故我先讓
Tr2先使用資源並全數鎖定X、Y,解鎖後再讓Tr1使用資源
Tr1 Tr2
-- -------------------------------
鎖定期 Luck_read(y)
Luck_read(X)
Luck_write(Y)
read Y
------------------------------------
解鎖期 Y=X+1000
Unluck_write(Y)
write Y
Unluck_read(Y)
Unluck_read(X)
------------------------------------
鎖定期 Luck_read(X)
Luck_write(X)
------------------------------------
X=X-1000
解鎖期
write X
Unluck_write(X)
Unluck_read(X)
請問可否這樣解?
Q2.若使用time-stamp執行,且Tr在Tr2之後才進來,說明執行結果
設 Tr1 起始時間200 Tr1起始時間100
且分別設定write/read的起始時間分別為 W_max=90 R_max=90
Time| Tr1 | Tr2
______________________
t1 | read X | // Tr1(200)>= R_max(90) , R_max=200
t2 | read Y //Tr2(100)<=R_max(200) , Tr2重跑 得到新的時間300
t3 | X=X-1000 |
t4 | | read X // Tr2(300)>=R_max(200) , R_max=300
t5 | write X | //Tr1(200)< R_max(300) ,Tr1(200)> W_max(90),但 Tr1仍
//需重跑 得到新的時間400
t6 | | Y=Y+1000
t7 | | write Y //Tr2(300)>=R_max(200) 且 Tr2(300)>W_max(90)
但參考了高點的解答,為何說該兩交易之排成可順利完成
請版上高手綁我檢視我的想法有沒有問題?或有那裡考慮的不周全?
--
Tags:
高考
All Comments
By Victoria
at 2015-05-08T13:51
at 2015-05-08T13:51
By Mary
at 2015-05-08T16:14
at 2015-05-08T16:14
By Tom
at 2015-05-10T06:46
at 2015-05-10T06:46
By Caitlin
at 2015-05-11T07:42
at 2015-05-11T07:42
By Annie
at 2015-05-15T01:23
at 2015-05-15T01:23
By Delia
at 2015-05-17T22:46
at 2015-05-17T22:46
By Harry
at 2015-05-19T12:47
at 2015-05-19T12:47
By Adele
at 2015-05-21T12:34
at 2015-05-21T12:34
By Sarah
at 2015-05-26T01:44
at 2015-05-26T01:44
By Tracy
at 2015-05-28T19:30
at 2015-05-28T19:30
By Dorothy
at 2015-05-30T15:39
at 2015-05-30T15:39
By Olivia
at 2015-06-02T22:26
at 2015-06-02T22:26
By Una
at 2015-06-03T20:02
at 2015-06-03T20:02
By John
at 2015-06-04T03:47
at 2015-06-04T03:47
By George
at 2015-06-04T11:47
at 2015-06-04T11:47
By Christine
at 2015-06-05T12:07
at 2015-06-05T12:07
By Edwina
at 2015-06-09T08:06
at 2015-06-09T08:06
By Franklin
at 2015-06-11T04:50
at 2015-06-11T04:50
Related Posts
在職,先求有再求好的考科選擇?
By Lauren
at 2015-05-03T22:41
at 2015-05-03T22:41
請問稅法申論怎麼寫
By Anonymous
at 2015-05-03T20:35
at 2015-05-03T20:35
準備人事這樣子的書單可以嗎?
By Genevieve
at 2015-05-02T21:58
at 2015-05-02T21:58
準備考試真的會沒朋友
By Victoria
at 2015-05-02T11:01
at 2015-05-02T11:01
高考和普考行政法的差異
By Rae
at 2015-05-02T00:01
at 2015-05-02T00:01