Linux基础练习_复习题

Q:It has been suggested that the first part of each UNIX file be kept in the same disk block as its i-node. What good would this do?

A:When reading the file, if the first partof file is kept in the same disk block with its i-node,fewer disk accesses will be needed.

In particular, if the file is short (i.e.the entire file is in one disk block), it costs only one disk access.


Q:The Unix File System uses i-nodes to index directories and files. Assume only the address of the data block for root directory is cached (known). All other contents stored in the File System are not cached. Assume the content of directories can be stored in only one data block. What are the disk operations needed to read the first byte of a file: /user/jlu/os_2015_exam.tex? Explain your answer.

A:The disk operations are as followings:
1. Directory for “/”
2. I-node for “/user”
3. Directory for “/user”
4. I-node for “/user/jlu”
5. Directory for “/user/jlu”
6. I-node for “/user/jlu/ os_2015_exam.tex”
In conclusion, we need six disk operations to read the first byte of this file.


Q:A computer has four page frames. The time of loading, time of last access, and the R (for read) and M (for modified) bits for each page are as shown below (the times are in clock ticks):

Pages

Loaded

Last ref

R

M

0

126

280

1

0

1

230

265

0

1

2

140

270

0

0

3

110

285

1

1

Consider four page replacementalgorithms:

a) Which page will FIFO replace?Justify!

b) Which page will NRU replace?Justify!

c) Which page will LRU replace?Justify!

d) Which page will secondchance replace?Justify!

A:

a) FIFO: Page 3 will be replaced.
Because the time of loading indicates that Page 3 is the oldest page.

b) NRU: Page 2 will be replaced.
Because the class order is:
Page2(class 0) < Page 1(class1) < Page 0(class2) < Page 3(class3).

c) LRU: Page 1 will be replaced.
Because the time of last reference indicates that Page 1 is the page that has been unused for the longest time.

d) Second chance: Page 2 will be replaced.
Because the algorithm works as followings:
-- It first looks at Page 3 which is the oldest. But the R bit is set, so it puts Page 3 onto the end of the list and clears the R bit.
-- Then it looks at Page 0 which is the second oldest. But again the R bit is set, so it does the same thing with Page 0.
-- Finally, when it looks at Page 2 which has the R bit cleared, it succeeds and Page 2 is removed.


Q:On a 32-bit machine, two-level page table are used. Top-level table uses 9 bits and second-level table uses 11 bits, what is the page size and how many pages?

A:There are 32-9-11=12 bits used for the offset, so the page size is 2^12=4096B=4KB. Since 20 bits are for virtual page table, we have 2^20=1048576 pages.
Conclusion: the page size is 4KB and there are 2^20(i.e.1048576) pages.


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值