Interviewer And Interviewee Guide

Linux Debugging Interview Question:

Which one of the following string will print first by this program?
#include<stdio.h>
#include<pthread.h>

void *fun_t(void *arg);
void *fun_t(void *arg)
{
printf("Googlen");
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
perror("pthread_create");
printf("Linuxn");
if(pthread_join(pt,&res_t) != 0)
perror("pthread_join");
return 0;
}
a) Linux
b) Google
c) it can not be predicted
d) none of the mentioned

Submitted by: Murtaza
b) Google
Explanation:It depends upon the scheduler.
Output:
[root@localhost Google]# gcc -o san san.c -lpthread
[root@localhost Google]# ./san
Google
Linux
[root@localhost threads]#
Submitted by: Murtaza

Read Online Linux Debugging Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.