作者taco205130 (taco)
看板Grad-ProbAsk
標題Re: [理工] [os]-政大97-資科
時間Wed Mar 3 12:26:41 2010
※ 引述《b76516 (阿聰)》之銘言:
: 4. Consider a file consisting of 40 blocks. Assume that the file control block
: (and the index block, in case of indexed allocation) is already in memory.
: Calculate how many disk I/O operations are required for contiguous, linked,
: and indexed(single-level) allocation strategies, if, for one block, the
: following conditions hold. In the contiguous allocation case, assume that
: there is no room to grow in the beginning, but there is room to grow in the
: end. Assume that the block information to be added is stored in memory.
: (1)The block is added at the beginning.
: (2)The block is added in the middle.
: (3)The block is removed from the middle.
: (4)The block is removed from the end.
: 答案寫說
: contiguous linked indexed
: (1) 81 1 1
: (2) 41 22 1
: (3) 38 22 0
: (4) 0 40 0
以下是我的想法 不知道對不對 大家幫忙看一下
如果先考慮題目10個blocks的話
coutigous:
(1)
原先的 1 2 3 4 5 6 7 8 9 0
要改成 * 1 2 3 4 5 6 7 8 9 0
則若有n個blocks 則需要 2*n+1
(2)
原先的 1 2 3 4 5 6 7 8 9 0
要改成 1 2 3 4 5 * 6 7 8 9 0
則若有n個blocks 則需要 2*n/2+1
(3)
原先的 1 2 3 4 5 6 7 8 9 0
要改成 1 2 3 4 5 7 8 9 0
則若有n個blocks 則需要 2*(n/2-1)
(4)
原先的 1 2 3 4 5 6 7 8 9 0
要改成 1 2 3 4 5 6 7 8 9
則不需要任何的disk動作
linked
(1)
1>2>3>4>5>6>7>8>9>0>null
*>1>2>3>4>5>6>7>8>9>0>null // *.point= 1 ps:(1位置在memory)
(2)
1>2>3>4>5>6>7>8>9>0>null
1>2>3>4>5>6 // read until 5
5>*>6 // *.point=5.point 5.point=*
(3)
1>2>3>4>5>6>7>8>9>0>null
1>2>3>4>5>6>7 // read until 6
5>7 // 5.point=6.point
(4)
1>2>3>4>5>6>7>8>9>0>null
1>2>3>4>5>6>7>8>9>0 // read until 9
9>null //9.point=null
index:
(1)(2)
需更改index block內容 與 寫入增加的block
但index block在memory 所以只須1次
(3)(4)
只需要改index block
謝謝大家摟~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.25.118.52
推 lightergogo:index block是存在memory 所以不用I/O 03/03 12:43
→ taco205130:那降indexed(1)(2)的1次是?? 03/03 14:41
→ taco205130:事就只有寫入新加的那個block嗎? 03/03 14:43
推 crazyjoe:YES 03/03 14:53
→ taco205130:喔屋我懂了! 03/03 14:54
※ 編輯: taco205130 來自: 163.25.115.23 (03/03 14:58)