Written Assignment 7

Question 1

Additional Benefits besides cache aspect:

  1. Virtual address simplifies memory management for processes because it provides an abstraction of linear address space. Therefore, each process can put specific data on their specific virtual address instead of having to worry about other process already used that portion of address.
  2. Because of (1) above, compiler can hard-code address space of virtual address.
  3. Virtual address protect a process' memory by isolate one memory space from another using page table. Therefore system will not be easily crashed by misbehavior of one program.
  4. Virtual address let application share parts of the same memory for libraries such as libc. This greatly reduced the memory needed for multiple processes since many processes use similar libraries.
  5. Copy-on-Write policy provide benefits for deferring calculations, which only exists using virtual address.

Question 2

Notice malloc is allocating large data using mmap(), only page table entry and swap file (maybe, depending on specific malloc implementation, malloc may try to write header or footer) is changed during the process.

There are many reasons why it could fail:

  1. Because page table is on physical memory, perhaps the physical memory is full (allocated by other processes) and therefore there is an error in creating the next-level page table for this process because it runs out of physical memory.
  2. The system implements page table badly and therefore 3GB memory require more than 64GB of physical memory.
  3. For some reason, mmap returns ENOMEM: No memory is available since process's maximum number of mappings would have been exceeded.
  4. mmap returns ENOMEM: program exceed soft or hard set by the kernel.
  5. The system has non-standard virtual address space that is too small, or virtual address space is full for this specific process.
  6. malloc tries to write header or footer, which result allocated space be in actual physical memory. Therefore, exceeding physical memory limit. (application hits RLIMIT_AS or RLIMIT_DATA)

Question 3

Virtual: 10 bits Physical: 8 bits Page Size: 32 byte

VIRTUAL PAGE NUMBER PHYSICAL PAGE NUMBER VALID
00 2 1
01 - 0
02 7 1
03 - 0

a. Because of page size, log_2(32) = 5 bits offset. Virtual page offsets always equal to physical page offsets. b. 0x04D = 0b1001101 (note: 0x represent hex, 0b represent binary)

c. 0x02B = 0b101011 (note: 0x represent hex, 0b represent binary)

Table of Content