Title Application for Implementing paging (swap file) support
Student Zhao Shuai
Mentor Ingo Weinhold
Abstract
Project Information
• Project Title: Implement paging (swap file) support
• List of project goals:
    Implement a module that writes dirty pages back to its backing store.
    Support more than 1 swap files.
    Do necessary changes in other modules to interact with the new features.
• Project description:
    A paging system has 2 features: the fetch policy and the replacement policy. The fetch policy determines when the system loads pages into memory and the replacement policy determines how the system selects pages to be removed from main memory when pages are unavailable for a placement request.
    I spent 2 days reading the Haiku vm source code and find that most facilities supporting the paging mechanism have been ready. The fetch policy has been accomplished; the replacement policy also has its skeleton done. But currently, the replacement algorithm just steals pages and put them into the dirty page queue; it doesn’t truly write pages back to the disk. What I need to do is to add a module (also a daemon, named pageout) to synchronize a cluster of modified pages to their backing stores. The module runs after specified time of intervals, calls the write function of the backing store to write pages back. It also clears modified bit in all MMU PTE entries wherever this page is mapped. It then sets page state to PAGE_STATE_ACTIVE if it being referenced otherwise its state is set to the PAGE_STATE_INACTIVE. Also this page is taken out, now, from modified queue and put in active pages queue.
    In order to support several swap files, I will add a vm_store structure for each swap file and implement its operations (destroy, read, write, etc).
Besides those 2 big tasks, some changes in other modules are needed. For example, we can use the vm_store_anonymous to replace the current vm_store_anonymous_noswap module. The page_daemon also need some changes to interact with the pageout daemon.