Process Management 1-2 Flashcards
What does fork do in a system process?
It creates a copy of itself, creates a new process by trapping OS and making it mostly duplicate
How many times does fork return when called?
Returns twice with each process @ the next instruction)
pid_t fork();
a system wide unique process identifier.
childs pid value is returned in the parent and parents pid is returned in the childs.
What is a forks order of execution?
nondeterministic , parent and child run concurrently.
Post fork, what relation do the parent and child functions have to each other?
They are identical but separate.OS allocates and maintains separate data /state
what if fork fails?
most syscalls will return -1 on failure
What happens to all terminating processes?
They turn into zombies, They become dead but still tracked by OS. -pid remains in use -exit status can be queried
Reaping processes
All processes are responsible for reaping their own immediate children processes
How do you kill a zombie process?
By killing/ terminating the parent process
What happens when the process is orphaned? ( The parent process is killed)
They are adopted by the OS kernel, reaping its children.
Why is it especially important for long running processes to reap their children?
Its important because zombie processes still consume system memory resources. if the parent terminates without reaping the children, then the kernel invokes the init process to reap them
Who reaps the parent?
The shell
what happens when the process is terminated and has more than 1 child?
reaps a zombie child
- returns reaped child’s pid and exit status
info via pointer
what happens when the process has no children when pid_ wait is called?
return -1 immediately populate errno
why are fork and exec separate calls?
They are separate because we might want to tweak the process before running a program in it.