Question: (a) What happens in Linux after a new process is created using fork()? Note, create() specifies what code to run as the child process through
(a) What happens in Linux after a new process is created using fork()? Note, create() specifies what code to run as the child process through its first argument (a function pointer).
(b) Determine who runs first: parent or child.
(c) As an app programmer, do you have a preference as to which process -- parent or child -- should run next in Linux? Explain your reasoning.
(d) For a child process created using fork() in Linux, it has to call execve() to make the child run executable code contained in a file (e.g., /bin/ls) as part of a file system specified in the argument of execve(). In Linux, sometimes an app programmer just wants to create a new process to run an existing binary without going through the 2-step procedure of fork() and execve(). Write a wrapper function, int newProcess(const char *filename), that internally calls fork() and execve() to make this happen where filename specifies the full pathname of an executable binary.
(e) How is newProcess() fundamentally different from the way XINU's create() works? (f) Ignore stack size and process priority which are specified as arguments in create(). How does Linux's clone() compare to XINU's create()?
(g) How does Linux's posix_spawn() compared to your newProcess() implementation? (h) Is there a best way to create processes? Explain your reasoning.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
