Question: Source: void *thread(void *vargp); char **ptr, int main(){ const int N = 2; int i; pthread_t tid[N]; char *msgs[N] = { Hello from foo, Hello

Source:
void *thread(void *vargp); char **ptr, int main(){ const int N = 2; int i; pthread_t tid[N]; char *msgs[N] = { "Hello from foo", "Hello from bar" }; printf("Parent thread started with PID = %d and parent PID %d ", getpid(), getppid()); ptr = msgs;
for(i=0;i for (i=0;i void *thread(void *vargp) { int myid = (int)vargp; static int cnt = 0; printf("[%d]:%s(cnt=%d) with PID= %d and parent PID %d ", myid, ptr[myid], ++cnt, getpid(), getppid()); int i= cnt; for(;;i++){ printf("[%d] %d ",myid,i); sleep(cnt); } return NULL; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
