let release_page ptable page_nb = let offset = ptable * page_size in memory.(offset + page_nb*2) <- int_of_mode UN; decr_ref_page memory.(offset + page_nb*2 + 1);; let brk system_state = if !verbose then Printf.eprintf "Brk\n%!"; let p = system_state.current in let new_memory_size = p.preg.(a0) in if new_memory_size > page_size*ptable_size then p.preg.(v0) <- -1 else begin let new_size = new_memory_size / page_size + 1 in let old_size = p.ptable_size in if new_size < old_size then for page_nb = new_size to old_size - 1 do release_page p.preg.(pt) page_nb done; p.ptable_size <- new_size; p.preg.(v0) <- 0 end; run system_state in system_traps.(sys_Brk) <- brk;; |