第15章 机制:地址转换

文章通过Python脚本`relocation.py`演示了在使用基址和界限寄存器的系统中,虚拟地址如何转换以及如何确定地址是否越界。读者需运行脚本并调整参数,例如种子值、生成地址数量、界限寄存器和基址寄存器的值,以理解不同设置对内存访问的影响。问题涉及确保地址在物理内存范围内、计算基址的最大值,以及研究界限寄存器值变化时有效地址的比例。
摘要由CSDN通过智能技术生成

Homework

The program relocation.py allows you to see how address translations are performed in a system with base and bounds registers. See the README for details.

Questions:

1. Run with seeds 1, 2, and 3, and compute whether each virtual address generated by the process is in or out of bounds. If in bounds, compute the translation.

python relocation.py -s 1 -c

python relocation.py -s 2 -c 

python relocation.py -s 3 -c

2. Run with these flags: -s 0 -n 10. What value do you have to set -l (the bounds register) to in order to ensure that all the generated virtual addresses are within bounds?

python relocation.py -s 0 -n 10 -l 1024 -c 

3. Run with these flags: -s 1 -n 10 -l 100. What is the maximum value that base can be set to, such that the address space still fits into physical memory in its entirety?

因为物理内存的默认大小为16K(即16384),而界限寄存器被设置为100,因此基址寄存器的最大值为16384 - 100 = 16284

 python relocation.py -s 1 -n 10 -l 100 -b 16284 -c

4. Run some of the same problems above, but with larger address spaces (-a) and physical memories (-p).

与第3题同理 

python relocation.py -s 1 -n 10 -l 100 -a 64K -p 1M -b 1048476 -c 

5. What fraction of randomly-generated virtual addresses are valid, as a function of the value of the bounds register? Make a graph from running with different random seeds, with limit values ranging from 0 up to the maximum size of the address space.

默认情况下:地址空间大小为1K,物理内存大小为16K

设界限寄存器的值为x,则x最小值为0,最大值为1024

则可用的地址空间为0 ~ x-1

 python relocation.py -s 3 -n 10 -l 512 -c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值