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