quiz

Process

1. What is a process in an operating system?

  • A) A program in execution
  • B) A set of instructions
  • C) Executable files
  • D) A collection of hardware components
A) A program in execution Explanation

2. When a program is loaded into memory and becomes a process, what are the four sections into which it is divided?

  • A) Text, data, heap, and stack
  • B) Kernel, user space, virtual memory, and cache
  • C) Input, processing, output, and storage
  • D) Registers, cache, RAM, and disk
A) Text, data, heap, and stack   Explanation

3. What are the possible states a process can be in an operating system?

  • A) New, ready, running, blocked, terminated
  • B) Active, inactive, suspended, completed
  • C) Created, terminated, waiting, halted
  • D) Sleep, ready, swapped, dead
A) New, ready, running, blocked, terminated Explanation

4. What does “spawning” refer to in the context of operating systems?

  • A) Terminating a process
  • B) Creating a new process
  • C) Blocking a process
  • D) Suspending a process
B) Creating a new process Explanation

5. Which of the following information is typically stored in the Process Control Block (PCB)?

  • A)  Process ID and parent process ID
  • B) Program code and data
  • C) CPU registers and program counter  
  • D) All of the above
D) All of the above Explanation

6. What is the process identifier of a null process in an operating system?

  • A) 0
  • B) 1
  • C) Null
  • D) -1

7. How often does the fork system call execute in the following code snippet?

#include <stdio.h> #include <unistd.h> int main() {     fork();     fork();     printf("Hello world\n");     return 0; }
  • A)  Once
  • B) Twice
  • C) Thrice
  • D) Four times
D) Four times Explanation

8. What is the return value of the fork system call in both the parent and child processes?

  • A) Parent process: -1, Child process: 0
  • B) Parent process: 0, Child process: -1
  • C) Parent process: -1, Child process: child's PID
  • D) Parent process: child's PID, Child process: 0
D) Parent process: child's PID, Child process: 0 Explanation