Consider the following code:
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
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 arecreated. (To answer this
question do not supply just the number of processes—explain yourreasoning).
Note: the answer is not 4.
c. How many unique threads are created? (To answer this ques- tiondo not supply just the number
of threads—explain your reasoning. Also remember, the initialprocess is thread 1).
Expert Answer
An answer will be send to you shortly.
PayPal Gateway not configured
PayPal Gateway not configured