作者crazyjoe (梨子)
看板Grad-ProbAsk
標題Re: [理工] [os]-政大97-資科
時間Tue Mar 2 20:53:57 2010
※ 引述《bigrat2 (MrEric)》之銘言:
: ※ 引述《b76516 (阿聰)》之銘言:
: : 剛好先前有鄉民問到同一題引用一下
: 我想請問 linked 的(2)(3)(4)
: 為什麼是22.22.40 呢?
: 謝謝大家的指教
: : 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
linked的
(2)20(找到中間)+1(改第20個的pointer到added block)+1(寫入addes block)=22
(3)21(找被刪的下一個block)+1(把被刪的上一個block指向剛剛找個block)=22
(4)最後一個被刪,要把他的前一個block指向null,所以要找39+1(寫入)=40
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.243.66
推 bigrat2:很清楚 謝謝指教 03/02 22:51
推 polomoss:如果是link的added in the end?? 03/02 22:53
推 bernachom:請教一下,那第一個呢??Y 03/02 22:54
推 bigrat2:add in the end 應該是3次 寫入block 改40的指標 改block 03/02 23:24
→ bigrat2:的指標到null 如果有錯誤請指教 03/02 23:25
推 polomoss:應該沒錯~我手上答案也是3 03/03 00:15