Question: Consider the following code: #include #include #include void *my_function(void *param); int main() { int i; pthread_t tid; pid_t pid; for(i=0; i <3; i++) { pid
Consider the following code: #include
void *my_function(void *param); int main() {
int i;
pthread_t tid;
pid_t pid;
for(i=0; i<3; i++) {
pid = fork(); pthread_create(&tid,NULL,my_function,NULL);
pthread_join(tid,NULL);
}
}
a. Explain what is happening within the for-loop. Your ex- planation must explain the purpose and effect of the three system calls.
b. Including the initial parent process, how many processes are created. (To answer this question do not supply just the number of processesexplain your reasoning). Note: the answer is not 4.
c. How many unique threads are created? (To answer this ques- tion do not supply just the number of threadsexplain your reasoning. Also remember, the initial process is thread 1).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
