let fork system_state = if !verbose then Printf.eprintf "Fork\n%!"; let p = system_state.current in let pid = system_state.new_pid () in if !verbose then Printf.eprintf "Son pid %d\n%!" pid; let son = { preg = Array.copy p.preg; pcode = system_state.current.pcode; quantum = 0; pid = pid; ppid = system_state.current.pid; state = Ready; ptable_size = p.ptable_size } in son.preg.(pt) <- clone_ptable p.preg.(pt) p.ptable_size; Hashtbl.add system_state.processes pid son; son.preg.(v0) <- 0; system_state.active_processes <- son :: system_state.active_processes; p.preg.(v0) <- pid; run system_state in system_traps.(sys_Fork) <- fork;; |