let incr_ref_page i = free_pages.(i) <- free_pages.(i) + 1;; let clone_ptable ptable size = let new_ptable = new_page () in copy_page ptable new_ptable; let offset = ptable * page_size in let new_offset = new_ptable * page_size in for i = 0 to size - 1 do match mode_of_int memory.(offset + 2*i) with | RW -> memory.(new_offset + 2*i) <- int_of_mode COW; memory.(offset + 2*i) <- int_of_mode COW; incr_ref_page memory.(offset + 2*i + 1) | COW -> incr_ref_page memory.(offset + 2*i + 1) | _ -> () done; new_ptable;; |