let fork system_state = if !verbose then Printf.eprintf "Fork\n%!"; let p = system_state.current in let pid = new_pid system_state 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 } in Hashtbl.add system_state.processes pid son; (* fork retourne la valeur 0 pour le fils *) son.preg.(v0) <- 0; system_state.active_processes := son :: !(system_state.active_processes); (* fork retourne la valeur pid pour le père *) p.preg.(v0) <- pid; (* on appelle l'ordonnanceur *) run system_state in (* on enregistre le code de fork dans la table des appels système *) system_traps.(sys_Fork) <- fork;; |