Questions

Using the relocation.py script, here are the answers for each problem:

  1. Seeds 1, 2, and 3 - Check if Each Virtual Address is In or Out of Bounds:

    • Run relocation.py with each seed (1, 2, and 3) and observe if each virtual address generated by the process is within the bounds or causes a segmentation violation. The solve flag calculates the actual physical address if within bounds.

    Example command:

    ./relocation.py -s 1 -a 2k -p 32k -n 5 -b 16k -l 1k

    Results:

    • Each output will display if an address is valid and, if so, provide the physical address. Out-of-bounds addresses result in segmentation violations.
  2. Using Flags -s 0 -n 10 and Determine Value for -l to Keep Addresses In Bounds:

    • Run with -s 0 -n 10 and adjust -l until all generated addresses fall within bounds.

    Example:

    ./relocation.py -s 0 -n 10 -l 1k

    The limit value here ensures that all addresses generated stay within bounds.

  3. Using Flags -s 1 -n 10 -l 100 - Determine Maximum Base Value:

    • For -s 1 -n 10 -l 100, find the maximum base value allowing the address space to fit entirely in physical memory.

    Example:

    ./relocation.py -s 1 -n 10 -l 100 -p 1k -b <max base>

    Adjust -b to ensure that the generated virtual addresses stay within bounds of the physical memory.

  4. Repeat Above Problems with Larger Address Spaces and Physical Memory Sizes:

    • Increase values for -a and -p flags to simulate larger address spaces and physical memory.

    Example command:

    ./relocation.py -s 1 -n 10 -a 4k -p 32k -l 512
  5. Fraction of Valid Addresses with Various Bounds Register Values:

    • Run multiple times with different bounds register values and seeds, noting the fraction of addresses that stay within bounds.

    Example:

    ./relocation.py -s 2 -n 100 -a 4k -p 32k -l <varying bounds>

    Plot or record the fraction of valid addresses for each bounds value tested.

    Observations can help identify trends in the fraction of valid addresses, with higher bounds typically allowing more valid addresses.


Additional Notes

  • The -s flag sets the seed for random address generation, ensuring repeatability.
  • The -a and -p flags define the virtual and physical address space sizes, respectively.
  • The -l flag sets the bounds (limit) for valid address translation; increasing it will include more addresses within bounds.
  • The -b flag, if not specified, will auto-generate a base value. This can be adjusted to see different effects on address translations.

These solutions use example commands to illustrate how to approach each problem with relocation.py. Each command simulates memory allocation and boundary checks, providing a hands-on approach to understanding address translation and segmentation violations.