Vidyalelo
Computer Science · Q612

Linux

Engineering and GATE · Computer Science · question 612

Q612

What is the output of this program? #include #include #include sem_t st; void *fun_t(void *arg); void *fun_t(void *arg) printf("Linux "); pthread_exit("Bye"); sem_post(&st); int main() pthread_t pt; void *res_t; if(pthread_create(&pt,NULL,fun_t,NULL) == -1) perror("pthread_create"); if(sem_init(&st,0,0) != 0) perror("sem_init"); if(sem_wait(&st) != 0) perror("sem_wait"); printf("Example "); if(pthread_join(pt,&res_t) == -1) perror("pthread_join"); if(sem_destroy(&st) != 0) perror("sem_destroy"); return 0;

A.
this program will print the only string "Linux"
Answer
B.
this program will print the only string "Example"
C.
this program will print both the strings "Linux" and "Example"
D.
none of the mentioned

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board