看板 Grad-ProbAsk 關於我們 聯絡資訊
※ 引述《taco205130 (taco)》之銘言: : ※ 引述《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 : 謝謝大家摟~ 借版大的文章發問一下 (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 -- linked的地方,為什麼(3)要read到6(刪除middle),而(4)只要read到9, 而不是read到0?(刪除end) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.3.86
dy957:我覺得是因為read6才能知道7的位址 而read到9直接寫成 NIL 01/27 00:12