B.1 Virtual memory

Qa:

Do I need to keep both global invert page table (IPT) and a per-process page table?

Ans:

No.

Qb:

Where is the swap file stored? How to read and write swap file?

Ans:

A swap file is a regular file in the stubFileSytem that can read and written using OpenFile.read() and OpenFile.write(). You may implement a private class for operations (open, delete, swap in, swap out, etc.) related to swap file. Swap file is organized in pages. Similar to IPT, you can use a hash table to store the mapping between <process id, virtual page number> and the index of swap page entry.

Qc:

With on-demand paging, shall I allocate all free physical pages when executing a process (loadSections)?

Ans:

This is implementation dependent. Some OS reserves a pool of free physical pages to reduce the latency for handling page faults. In Linux, code section of the process is on disk (the executable becomes part of the swap file). In your implementation, you may choose to put as many pages in the physical memory as possible and let on-demand paging handle the rest if no free physical pages are available.

Qd:

How to generate page faults using matmult.c?

Ans:

In matmult.c, 3 integer arrays of size DIMxDIM are statically allocated. By changing the value of DIM, you can make the total memory requirement exceeds the # of pages of physical memory. (Alternatively, you can also reduce the # of physical pages in the config file.

Qe:

Ans:

Qf:

Ans:

Qg:

Ans: