Linux Debugging Questions & Answers – Timer, User & Resource Limit System Calls

Basic Computer Knowledge Test Questions and Answers

1.

This program will print the

  1.    #include<stdio.h>
  2.    #include<unistd.h>
  3. 
     
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = sysconf(_SC_CHILD_MAX);
  8.        printf("%ld\n",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 these

Answer: Option 'A'

maximum number of simultaneous processes per user id

Basic Computer Knowledge Test Questions and Answers

2.

This program will print the

  1.    #include<stdio.h>
  2.    #include<unistd.h>
  3. 
     
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = sysconf(_SC_OPEN_MAX);
  8.        printf("%ld\n",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 these

Answer: Option 'A'

maximum number of threads in current process

Basic Computer Knowledge Test Questions and Answers

3.

This program will print the

  1.    #include<stdio.h>
  2.    #include<unistd.h>
  3. 
     
  4.    int main()
  5.    {
  6.        long int value;
  7.        value = pathconf("/home/sanfoundry",_PC_NAME_MAX);
  8.        printf("%ld\n",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 these

Answer: Option 'B'

maximum length of a filename in this directory that the process is allowed to create

Basic Computer Knowledge Test Questions and Answers

4.

What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<unistd.h>
  3.    #include<fcntl.h>
  4. 
     
  5.    int main()
  6.    {
  7.        long int value;
  8.        int fd;
  9.        fd = open("/home/sanfoundry/san.c",O_RDONLY);
  10.        value = fpathconf(fd,_PC_LINK_MAX);
  11.        printf("%ld\n",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 these

Answer: Option 'A'

this program will print the maximum number of links to the file “san.c”

Basic Computer Knowledge Test Questions and Answers

5.

This program will print the

  1.    #include<stdio.h>
  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("%lu\n",limit.rlim_cur);
  10.        printf("%lu\n",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 these

Answer: Option 'C'

soft 7 hard limit of the size of the file in bytes that can be created by the process

Basic Computer Knowledge Test Questions and Answers

6.

What is the output of this program?

  1.    #include<stdio.h>
  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("%lu\n",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 these

Answer: Option 'A'

[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
4096
[root@localhost sanfoundry]#

Basic Computer Knowledge Test Questions and Answers

7.

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

  1.    #include<stdio.h>
  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("%lu\n",limit.rlim_cur);
  15.        printf("%lu\n",limit.rlim_max);
  16.        return 0;
  17.    }

   A.) 10
   B.) 20
   C.) permisssion denied
   D.) none of these

Answer: Option 'B'

20

Basic Computer Knowledge Test Questions and Answers

8.

What is the output of this program?

  1.    #include<stdio.h>
  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 these

Answer: Option 'C'

permission denied

Basic Computer Knowledge Test Questions and Answers

9.

What is the output of this program?

  1.    #include<stdio.h>
  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("%lu\n",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 these

Answer: Option 'A'

maximum size of a core file that can be created by this process

Basic Computer Knowledge Test Questions and Answers

10.

What is the output of this program?

  1.     #include<stdio.h>
  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("%lu\n",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 these

Answer: Option 'B'

maximum size of total available storage for this process in bytes

Linux Debugging Questions & Answers – Timer, User & Resource Limit System Calls Download Pdf

Recent Posts