21. What is the output of this program?
#include<stdio.h>
#include<pthread.h>
#include<semaphore.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
sem_post(&st);
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
sem_t st;
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\n");
if(pthread_join(pt,&res_t) == -1)
perror("pthread_join");
if(sem_destroy(&st) != 0)
perror("sem_destroy");
return 0;
}
#include<stdio.h>
#include<pthread.h>
#include<semaphore.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
sem_post(&st);
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
sem_t st;
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\n");
if(pthread_join(pt,&res_t) == -1)
perror("pthread_join");
if(sem_destroy(&st) != 0)
perror("sem_destroy");
return 0;
}
22. Sysfs represents the
23. In awk, the built-in variable FS is
24. What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0&&$a<100 ))
echo $b
exit 0
#!/bin/bash
a=10
b=$(( $a<0&&$a<100 ))
echo $b
exit 0
25. What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
struct data_st{
long int id;
char buff[11];
};
int main()
{
int m_id,ret;
struct data_st data1, data2;
m_id = msgget((key_t)181,0666|IPC_CREAT);
if(m_id == -1)
perror("msgget");
data1.id = 1;
strcpy(data1.buff,"Example");
ret = msgsnd(m_id,&data1,11,0);
printf("%d\n",ret);
if(msgrcv(m_id,&data2,11,1,0) == -1)
perror("msgrcv");
if(msgctl(m_id,IPC_RMID,0) != 0)
perror("msgctl");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
struct data_st{
long int id;
char buff[11];
};
int main()
{
int m_id,ret;
struct data_st data1, data2;
m_id = msgget((key_t)181,0666|IPC_CREAT);
if(m_id == -1)
perror("msgget");
data1.id = 1;
strcpy(data1.buff,"Example");
ret = msgsnd(m_id,&data1,11,0);
printf("%d\n",ret);
if(msgrcv(m_id,&data2,11,1,0) == -1)
perror("msgrcv");
if(msgctl(m_id,IPC_RMID,0) != 0)
perror("msgctl");
return 0;
}
26. What is the output of this program?
#include<stdio.h>
#include<pthread.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
sleep(1);
}
int main()
{
pthread_t pt;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
perror("pthread_create");
if(pthread_join(pt,&res_t) != 0)
perror("pthread_join");
printf("%s\n",res_t);
return 0;
}
#include<stdio.h>
#include<pthread.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
sleep(1);
}
int main()
{
pthread_t pt;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
perror("pthread_create");
if(pthread_join(pt,&res_t) != 0)
perror("pthread_join");
printf("%s\n",res_t);
return 0;
}
27. If user tries to remove (rm) a readonly file (444 permission), what will happen?
28. The user can define a command for GDB with the command
29. On Linux, initrd is a file
30. Which one of the following is not a valid makefile directive?
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.