Linux - Study Mode

[#941] What is the output of this program? #include<stdio.h>
#include<pthread.h>
#include<semaphore.h>

sem_t st
void *fun_t(void *arg)
void *fun_t(void *arg)
{
printf("Linux
")
pthread_exit("Bye")
}
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,2) != 0)
perror("sem_init")
if(sem_wait(&st) != 0)
perror("sem_wait")
printf("Example
")
if(sem_wait(&st) != 0)
perror("sem_wait")
if(pthread_join(pt,&res_t) == -1)
perror("pthread_join")
if(sem_destroy(&st) != 0)
perror("sem_destroy")
return 0
}
Correct Answer

(C) this program will print both the strings "Linux" and "Example"

[#942] What is the output of this program #include<stdio.h>
#include<pthread.h>

void *fun_t(void *arg)
void *fun_t(void *arg)
{
pthread_exit("Bye")
}
int main()
{
pthread_t pt
void *res_t
int ret
ret = pthread_join(pt,&res_t)
printf("%d
",ret)
return 0
}
Correct Answer

(D) 3

[#943] What is the output of this program? #include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>

int main()
{
struct rlimit limit
if(getrlimit(RLIMIT_DATA,&limit) != 0)
perror("getrlimit")
printf("%lu
",limit.rlim_max)
return 0
}
Correct Answer

(B) maximum size of total available storage for this process in bytes

[#944] What is the output of this program? #include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>

int main()
{
int fd
fd = socket(AF_UNIX,SOCK_STREAM,0)
printf("%d
",fd)
return 0
}
Correct Answer

(D) 3

[#945] In the output of this program, the string "/* Linux */" will be added at the . . . . . . . . of the source file. #include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

int main()
{
int fd
fd = open("test.c",O_RDWR|O_APPEND)
write(fd,"/* Linux */",11)
return 0
}
Correct Answer

(A) end