第16章 分段

Homework

This program allows you to see how address translations are performed in a system with segmentation. See the README for details.

Questions

1. First let’s use a tiny address space to translate some addresses. Here’s a simple set of parameters with a few different random seeds; can you translate the addresses?

python segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 0 -c

python segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 1 -c

python segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 2 -c 

2. Now, let’s see if we understand this tiny address space we’ve constructed (using the parameters from the question above). What is the highest legal virtual address in segment 0? What about the lowest legal virtual address in segment 1? What are the lowest and highest illegal addresses in this entire address space? Finally, how would you run segmentation.py with the -A flag to test if you are right?

段0合法虚拟地址:0x00000000 (decimal:      0) -- 0x00000013 (decimal:   19)

段1合法虚拟地址:0x0000006c (decimal:  108) -- 0x0000007f (decimal:  127)

在整个地址空间中,最低位的不合法虚拟地址是:0x00000014 (decimal:   20)

                                最高位的不合法虚拟地址是:0x0000006b (decimal:  107)

python segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -A 19,20,107,108,127 -c 

3. Let’s say we have a tiny 16-byte address space in a 128-byte physical memory. What base and bounds would you set up so as to get the simulator to generate the following translation results for the specified address stream: valid, valid, violation, ..., violation, valid, valid? Assume the following parameters:

答案不唯一,但段0和段1的界限寄存器都必须设置为2

python segmentation.py -a 16 -p 128 -A 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 --b0 0 --l0 2 --b1 128 --l1 2 -c

4. Assume we want to generate a problem where roughly 90% of the randomly-generated virtual addresses are valid (not segmentation violations). How should you configure the simulator to do so? Which parameters are important to getting this outcome?

只要保证段0和段1的界限寄存器之和为地址空间大小的90%

 python segmentation.py -a 16 -p 128 --b0 0 --l0 7 --b1 128 --l1 7 -c

 5. Can you run the simulator such that no virtual addresses are valid? How?

段0和段1的界限寄存器都为0即可

python segmentation.py -a 16 -p 128 --b0 0 --l0 0 --b1 128 --l1 0 -c 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值