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]#
d) none of the mentioned
Explanation:
The function pthread_exit() does not return any value. Hence this program will give an error.
Output:
[root@localhost Google]# gcc -o san san.c -lpthread
san.c: In function 'fun_t':
san.c:8:6: error: void value not ignored as it ought to be
[root@localhost google]#
b) this program will print nothing
Explanation:The pthread_join() function waits for the thread to terminate.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
[root@localhost google]#
d) none of the mentioned
Explanation:
Each thread has its own stack so local variables are not shared among thread. Hence this program will give an error.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
san.c: In function 'fun_t':
san.c:7:16: error: 'a' undeclared (first use in this function)
san.c:7:16: note: each undeclared identifier is reported only once for each function it appears in
[root@localhost google]#
a) 10
Explanation:
Thread of the same process shares the global variables.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
10
[root@localhost google]#
b) 20
Explanation:
In this program the value of variable "a" is changed by the thread "fun_t".
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
20
[root@localhost google]#
a) both printf statements will print the same value
Explanation:
All the threads of the same process have same PID.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
12981
12981
[root@localhost google]#
a) 10
Explanation:
Open file descritpors can be shares between threads of the same process
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
10
[root@localhost google]#
b) Bye
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
Bye
[root@localhost google]#
b) segmentation fault
Explanation:
This program is trying to print the return value of the thread, but pthread_exit() function is not present in the thread.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
Segmentation fault (core dumped)
[root@localhost google]#
a) gcc -g -o google google.c
c) both (a) and (b)
a) GNU debugger
15. GDB can be used for:
a) c language
b) c++ language
c) both (a) and (b)
d) none of the mentioned
c) both (a) and (b)
a) will start debugging for the file "google" if the file is compiled with -g option with GCC
c) both (a) and (b)
a) GDB will repeat the same command you just gave it
a) delete