Skip to main content

Operating System MCQs with Answers

Practice important Operating System MCQs with answers and explanations.

Chapter: 8
Q201:
In the context of UNIX/Linux IPC, which system call is used to close a file descriptor?
A. read()
B. write()
C. close()
D. fork()
Correct Answer: C
Chapter: 8
Q202:
A link in direct communication is associated with ______.
A. More than two processes
B. Exactly two processes
C. A mailbox
D. A shared memory
Correct Answer: B
Chapter: 8
Q203:
The pipe() system call returns how many file descriptors?
A. One
B. Two
C. Three
D. Four
Correct Answer: B
Chapter: 8
Q204:
In indirect communication, messages are sent to a ______.
A. Process
B. Mailbox
C. Shared memory
D. File descriptor
Correct Answer: B
Chapter: 8
Q205:
The sender in a blocking send scenario will ______.
A. Wait until the message is received
B. Continue its operation immediately
C. Block until the message is written
D. Not block, even if the message is not received
Correct Answer: A
Chapter: 8
Q206:
Which of the following is true about asynchronous communication in IPC?
A. The sender does not wait for the receiver
B. The sender waits for the receiver to acknowledge
C. Both sender and receiver must block
D. Communication only occurs when the queue is full
Correct Answer: A
Chapter: 8
Q207:
In the sample code provided, what happens when the child process writes to the pipe?
A. The parent process reads from the pipe
B. The child process reads from the pipe
C. Both processes write to the pipe simultaneously
D. The pipe gets closed automatically
Correct Answer: A
Chapter: 8
Q208:
What is the maximum number of bytes that can be written to a pipe in UNIX/Linux without blocking?
A. PIPE_BUF
B. 1024 bytes
C. 4096 bytes
D. 5120 bytes
Correct Answer: A
Chapter: 8
Q209:
The pipefd[1] descriptor in UNIX/Linux IPC is used for ______.
A. Reading from the pipe
B. Writing to the pipe
C. Closing the file descriptor
D. Receiving messages from the parent process
Correct Answer: B
Chapter: 8
Q210:
Which of the following is an example of a synchronization method used in IPC?
A. Blocking send
B. Shared memory
C. Named pipe
D. Pipe
Correct Answer: A
Chapter: 9
Q211:
What is the primary purpose of a pipe in UNIX/Linux?
A. Communication between unrelated processes
B. Communication between related processes
C. Data storage
D. File management
Correct Answer: B
Chapter: 9
Q212:
A FIFO (Named Pipe) in UNIX/Linux is used for communication between:
A. Related processes
B. Unrelated processes
C. Both related and unrelated processes
D. Only one process
Correct Answer: C
Chapter: 9
Q213:
The open() system call in UNIX/Linux is used to:
A. Close a file
B. Create or open a file
C. Write data to a file
D. Read data from a file
Correct Answer: B
Chapter: 9
Q214:
In the open() system call, what does the 'O_RDONLY' flag specify?
A. Open the file for reading
B. Open the file for writing
C. Open the file for both reading and writing
D. Open the file in non-blocking mode
Correct Answer: A
Chapter: 9
Q215:
What system call is used to read data from a file in UNIX/Linux?
A. open()
B. write()
C. read()
D. fork()
Correct Answer: C
Chapter: 9
Q216:
What does the write() system call in UNIX/Linux do?
A. Reads data from a file
B. Opens a file for writing
C. Writes data to a file
D. Closes a file
Correct Answer: C
Chapter: 9
Q217:
The close() system call is used to:
A. Open a file
B. Close a file descriptor
C. Allocate a file descriptor
D. Write data to a file
Correct Answer: B
Chapter: 9
Q218:
The pipe system call can fail if:
A. The file is locked
B. Too many files or pipes are open
C. The buffer size is too small
D. The disk is full
Correct Answer: B
Chapter: 9
Q219:
What happens if the read() system call fails?
A. It returns 0
B. It returns -1 and sets errno
C. It automatically retries
D. It terminates the program
Correct Answer: B
Chapter: 9
Q220:
The file descriptor returned by the open() system call is used for:
A. Reading and writing data
B. Managing memory
C. File creation
D. Process termination
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Operating System

🚀 Start Quiz Now