6,534
edits
Changes
m
→Removing an existing reference: use source tag
; The last reference is removed
: In this case the PB that ties page and UB must give its shift back to other PBs and be removed from list. This “giving shift back” procedure may involve three PBs and it is better described by the code example below.
<presource lang="C">
pb = lookup_pb(page, UB);
pb.refcount--;
page.pb_list.first = tail
}
</presource>
Decrementing the shifts like this means “take the fraction held by the PB going out and give it to another one; if the fraction held is too large — share it between two PBs”.
{{Note|cases when <code>page.pb_list</code> is becoming empty on adding a reference, or becoming empty on removing references are skipped to simplify the code examples.}}