250+ TOP MCQs on System Calls Basics and Answers

Unix Multiple Choice Questions on “System Calls Basics”.

1. A system call is a routine built into the kernel and performs a basic function.
a) True
b) False

Answer: a
Clarification: All UNIX systems offer around 200 special functions known as system calls. A system call is a routine built into the kernel and performs a very basic function that requires communication with the CPU, memory and devices.

2. When we execute a C program, CPU runs in ____ mode.
a) user
b) kernel
c) supervisory
d) system

Answer: a
Clarification: When we execute a C program, the CPU runs in user mode. It remains it this particular mode until a system call is invoked.

3. In ____ mode, the kernel runs on behalf of the user.
a) user
b) kernel
c) real
d) all

Answer: b
Clarification: Whenever a process invokes a system call, the CPU switches from user mode to kernel mode which is a more privileged mode. The kernel mode is also called as supervisor mode. In this mode, the kernel runs on behalf of the user and has access to any memory location and can execute any machine instruction.

4. All UNIX and LINUX systems have one thing in common which is ____
a) set of system calls
b) set of commands
c) set of instructions
d) set of text editors

Answer: a
Clarification: As we know that, all UNIX and LINUX systems have one thing in common; they use the same set of system calls.

5. The chmod command invokes the ____ system call.
a) chmod
b) ch
c) read
d) change

Answer: a
Clarification: Many commands and system calls share the same names. For example, the chmod command invokes the chmod system call.

6. For reading input, which of the following system call is used?
a) write
b) rd
c) read
d) change

Answer: c
Clarification: The standard C library offers a set of separate functions to read a block of data. For example, to read a block of data fread is used, for reading a line fgets is used and for reading a character fgetc is used. All these functions invoke the system call -read, which is available for reading input.

7. Which of the following system call is used for opening or creating a file?
a) read
b) write
c) open
d) close

Answer: c
Clarification: To read or write to a file, we first need to open it. For this purpose, open system call is used. Open has two forms ; the first forms assumes that the file already exists and the second form creates the file if it doesn’t.

8. There are ___ modes of opening a file.
a) 4
b) 3
c) 2
d) 1

Answer: b
Clarification: There are three modes of opening a file, out of which only one mode is required to be specified while opening the file. The three modes are, O_RDONLY, O_WRONLY, O_RDWR.

9. Which of the following mode is used for opening a file in both reading and writing?
a) O_RDONLY
b) O_WRONLY
c) O_RDWR
d) O_WDR

Answer: c
Clarification: There are three modes of opening a file namely:

 O_RDONLY    -    opens files for reading
 O_WRONLY    -    opens file for writing 
 O_RDWR      -   opens file for reading and writing

10. open system call returns the file descriptor as ___
a) int
b) float
c) char
d) double

Answer: c
Clarification: open returns the file descriptor as an int. This is the lowest number available for allocation and is used as an argument by the other four calls (read, write, close, lseek).

Leave a Reply

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