Question: Process-based forking and thread-based forking are two different semantics for fork() system call on multithreading. 1. Draw a process tree for both semantics (use P,
Process-based forking and thread-based forking are two different semantics for fork() system call on multithreading.
1. Draw a process tree for both semantics (use P, SP, SSP, to indicate the main process, sub-process, sub-sub-process, ; use P(n) to indicate a process with n extra threads.);
2. For each case, how many new processes have been created? and how many extra threads have been created?
pid_t pid;
pid = fork();
if (pid == 0) { /* child process */
fork();
thread_create( . . .);
}
else {
thread_create( . . .); }
fork();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
