This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “System Calls Basics – 1”.
1. A system call is a routine built into the kernel and performs a basic function.
a) True
b) False
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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).
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Unix Internship
- Check Unix Books
- Practice MCA MCQs
- Check MCA Books
- Practice Computer Science MCQs