Check out the new USENIX Web site. next up previous
Next: 3.4 Swapping Out (rw_swap_page) Up: 3 Prototype Description Previous: 3.2 Getting Free Space

3.3 Freeing a Page (swap_free)

Freeing a page consists of decrementing the number of processes that are using the page (swap_map[i]-). Whenever this becomes zero, the system has to free this space from the cache buffer or the disk block. This is done by decrementing the number of compressed pages in its disk block or cache buffer (physical_swap[i]-). Should this page be the last one in the buffer, the whole buffer should also be freed to be used by other pages in the future.

The above scenario is the best possible case. For mutual exclusion reasons, the order in which the operations are done can be broken and a page might be freed while a write operation is still pending. In this case, the page is marked to be freed as soon as the pending operations are finished. We will see this while describing the swapping in and out operations.

Another important issue related to freeing a page is the recompactation of blocks and buffers. If the page that is being freed was stored in the middle of a block or buffer, we could think of reallocating all pages together to merge this new space with the free space already remaining in the block or buffer. Doing this on disk blocks is completely out of the question as it would mean reading the disk (too much overhead). Recompacting cache buffers is a feasible task but we have seen that it does not increase the performance of the system and makes the code more complex [3]. For these reasons, we will never reuse the space of a freed page until all the compressed pages in a block or buffer have been freed.



Toni Cortes
Tue Apr 27 17:43:22 MET DST 1999