250+ TOP MCQs on Timer, User & Resource Limit System Calls and Answers

Linux Debugging questions and answers focuses on Timer, User and Resource Limit System Calls.1. This program will print the

  1.    #include
  2.    #include
  3. 
    
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = sysconf(_SC_CHILD_MAX);
  8.        printf("%ldn",value);
  9.        return 0;
  10.    }

a) maximum number of simultaneous processes per user id
b) maximum number of child processes of the current process
c) minimum number of simultaneous processes per user id
d) none of the mentioned

Answer: a

2. This program will print the

  1.    #include
  2.    #include
  3. 
    
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = sysconf(_SC_OPEN_MAX);
  8.        printf("%ldn",value);
  9.        return 0;
  10.    }

a) maximum number of threads in current process
b) maximum number of files that a process can have open at a time
c) segmentation fault
d) none of the mentioned

Answer: a

3. This program will print the

  1.    #include
  2.    #include
  3. 
    
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = pathconf("/home/",_PC_NAME_MAX);
  8.        printf("%ldn",value);
  9.        return 0;
  10.    }

a) maximum numbers of the file that can store in this directory
b) maximum length of a filename in this directory that the process is allowed to create
c) segmentation fault
d) none of the mentioned

Answer: b

4. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    int main()
  6.    {
  7.        long int value;
  8.        int fd;
  9.        fd = open("/home//san.c",O_RDONLY);
  10.        value = fpathconf(fd,_PC_LINK_MAX);
  11.        printf("%ldn",value);
  12.        return 0;
  13.    }

a) this program will print the maximum number of links to the file “san.c”
b) this program will print nothing
c) this program will give an error
d) none of the mentioned

Answer: a

5. This program will print the

  1.    #include
  2.    #include<sys/time.h>
  3.    #include<sys/resource.h>
  4. 
    
  5.    int main()
  6.    {
  7.        struct rlimit limit;
  8.        getrlimit(RLIMIT_FSIZE,&limit);
  9.        printf("%lun",limit.rlim_cur);
  10.        printf("%lun",limit.rlim_max);
  11.        return 0;
  12.    }

a) soft limit of the size of the file in bytes that can be created by the process
b) hard limit of the size of the file in bytes that can be created by the process
c) soft 7 hard limit of the size of the file in bytes that can be created by the process
d) none of the mentioned

Answer: c

6. What is the output of this program?

  1.    #include
  2.    #include<sys/time.h>
  3.    #include<sys/resource.h>
  4. 
    
  5.    int main()
  6.    {
  7.        struct rlimit limit;
  8.        if(getrlimit(RLIMIT_NOFILE,&limit) != 0)
  9.            perror("getrlimit");
  10.        printf("%lun",limit.rlim_max);
  11.        return 0;
  12.    }

a) this program will print the maximum numbers of the file descriptors that can be opened by a process
b) this program will print the maximum numbers of the child processes of the current process
c) this program will give an error because RLIMIT_NOFILE does not exist
d) none of the mentioned

Answer: a

7. The hard limit of the file descriptors that can be opened by this process will become

  1.    #include
  2.    #include<sys/time.h>
  3.    #include<sys/resource.h>
  4. 
    
  5.    int main()
  6.    {
  7.        struct rlimit limit;
  8.        limit.rlim_cur = 10;
  9.        limit.rlim_max = 20;
  10.        if(setrlimit(RLIMIT_NOFILE,&limit) != 0)
  11.            perror("setrlimit");
  12.        if(getrlimit(RLIMIT_NOFILE,&limit) != 0)
  13.            perror("getrlimit");
  14.        printf("%lun",limit.rlim_cur);
  15.        printf("%lun",limit.rlim_max);
  16.        return 0;
  17.    }

a) 10
b) 20
c) permisssion denied
d) none of the mentioned

Answer: b
Clarification: None.

8. What is the output of this program?

  1.    #include
  2.    #include<sys/time.h>
  3.    #include<sys/resource.h>
  4. 
    
  5.    int main()
  6.    {
  7.        struct rlimit limit;
  8.        limit.rlim_cur = 10;
  9.        if(setrlimit(RLIMIT_NOFILE,&limit) != 0)
  10.            perror("setrlimit");
  11.        return 0;
  12.    }

a) the soft limit of the file decriptors that can be opened by this process will become 10
b) the hard limit of the file decriptors that can be opened by this process will become 10
c) permission denied
d) none of the mentioned

Answer: c

9. What is the output of this program?

  1.    #include
  2.    #include<sys/time.h>
  3.    #include<sys/resource.h>
  4. 
    
  5.    int main()
  6.    {
  7.        struct rlimit limit;
  8.        if(getrlimit(RLIMIT_CORE,&limit) != 0)
  9.            perror("getrlimit");
  10.        printf("%lun",limit.rlim_max);
  11.        return 0;
  12.    }

a) maximum size of a core file that can be created by this process
b) maximum number of core files that can be created by this process
c) segmentaion fault
d) none of the mentioned

Answer: a

10. What is the output of this program?

  1.     #include
  2.     #include<sys/time.h>
  3.     #include<sys/resource.h>
  4. 
    
  5.     int main()
  6.     {
  7.         struct rlimit limit;
  8.         if(getrlimit(RLIMIT_DATA,&limit) != 0)
  9.             perror("getrlimit");
  10.         printf("%lun",limit.rlim_max);
  11.         return 0;
  12.     }

a) maximum size of data segment of this process in bytes
b) maximum size of total available storage for this process in bytes
c) segmentaion fault
d) none of the mentioned

Answer: b

Leave a Reply

Your email address will not be published. Required fields are marked *