> For the complete documentation index, see [llms.txt](https://pkuflyingpig.gitbook.io/pintos/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pkuflyingpig.gitbook.io/pintos/project-description/lab3a-demand-paging/suggestions.md).

# Suggestions

## Suggested Order of Implementation

We suggest the following initial order of implementation:

* **Frame table** (see section [Managing the Frame Table](/pintos/project-description/lab3a-demand-paging/background.md#managing-the-frame-table)).
  * Change `process.c` to use your frame table allocator.
  * **Do not implement swapping yet.** If you run out of frames, fail the allocator or panic the kernel.
  * After this step, your kernel should still pass all the project 2 test cases.
* **Supplemental page table and page fault handler** (see section[ Managing the Supplemental Page Table](/pintos/project-description/lab3a-demand-paging/background.md#managing-the-supplemental-page-table)).
  * Change `process.c` to record the necessary information in the supplemental page table when loading an executable and setting up its stack.
  * Implement loading of code and data segments in the page fault handler.
  * For now, consider only valid accesses.
  * After this step, your kernel should pass all of the project 2 functionality test cases, but only some of the robustness tests.
* From here, you can **implement page reclamation on process exit**.
* The next step is to **implement eviction** (see section [Managing the Frame Table](/pintos/project-description/lab3a-demand-paging/background.md#managing-the-frame-table)).
  * Initially you could choose the page to evict randomly.
  * At this point, you need to consider how to manage accessed and dirty bits and aliasing of user and kernel pages.
  * **Synchronization** is also a concern: how do you deal with it if process A faults on a page whose frame process B is in the process of evicting?
  * Finally, implement a eviction strategy such as the clock algorithm.
