The holy bible of SWEB - Institute of Applied Information Processing ...
The holy bible of SWEB - Institute of Applied Information Processing ...
The holy bible of SWEB - Institute of Applied Information Processing ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3.7. EXTENDING <strong>SWEB</strong> CHAPTER 3. VM, PROTECTION AND PAGING<br />
Figure 3.4: Page-Fault-Handling with possible CopyOnWrite<br />
3.7.5 CopyOnWrite<br />
A more efficient way, would be not to copy all pages, but, on demand, only copy pages<br />
that get modified. Such a mechanism is called CopyOnWrite. We might implement<br />
CopyOnWrite in Sweb by first marking all user pages as read-only. When creating a<br />
new process, instead <strong>of</strong> copying the kernel page directory, we copy the one from the<br />
original user process. This way, we can save memory space as well as the time it takes<br />
to create a new user process.<br />
Because both user process pages are read-only, writing on them will cause a page<br />
fault. Flag WP in CR0 should be set, so this happens even on a write performed by<br />
kernel code. To copy pages on demand the page fault handler needs to be modified to<br />
recognise a shared page and copy that page to a new location where it can be written<br />
to. An example <strong>of</strong> how the page fault handler might work can be found in Figure 3.4.<br />
Obvious care is necessary in administrating shared physical pages, i.e. a shared<br />
page can only be freed if all user processes using it have terminated. A possible<br />
solution might be to manage a reference counter for each physical page, however in<br />
combination with virtual memory this is not enough.<br />
48 <strong>of</strong> 151