diff --git a/content/notes/17-processes-communication.md b/content/notes/17-processes-communication.md index a077929af..27d04847a 100644 --- a/content/notes/17-processes-communication.md +++ b/content/notes/17-processes-communication.md @@ -15,10 +15,32 @@ defn: independent process - one does not affect the other and they do not commun # creating a child process A child process is creating from a parent using fork. -everything the same as the parent except the child has a differnent process ID. + +fork returns a value. 0 for the parent, and the id of the child for the child + +everything the same as the parent except the child has a differnent process ID. e.g., when they start they the same heap location etc. but as the child runs it may change. + +if you kill the parent before the child the child becomes an orhpan process +if yo ukill the child while the parent is waiting for the child the parent becomes a zombie (defunct) process. -- but only if the parent doesn't wait for the child. + +the child process can also call exexlp (load program) which erases the copy of the parent (itself not the parent) +- when initally forked the child and parent share the same space +- when the child calls execlp then the child will fully copy the program to a new memory location so it doesn't overwrite the parent # communcation between parent and child process create a chld process to do a task. but they need to communicate +after a process calls a chld process. it can execute a wait system call. + +this moves a process off the ready queue, untill the chld process has terminated +when the child process has terminated, it can return its status to the parent. + +# process termination +automatically executes exit after the last statement. +- may return status to parent who is `wait`ing +- all rsouces are dallocated by the OS + + they can also die more violently + # signal and pipe for inter process communication