Operating Systems and system Programming
Process in Operating Systems – MCQs with Answers
1. What is a process in an operating system?
A. A single instruction in execution
B. A collection of files
C. A program in execution
D. A program loaded in memory
✅ Answer: C. A program in execution
2. Which of the following is NOT a process state?
A. Ready
B. Running
C. Executing
D. Waiting
✅ Answer: C. Executing
3. Which data structure is used by the OS to keep track of processes?
A. Process Table
B. Stack
C. Job Queue
D. Ready Queue
✅ Answer: A. Process Table
4. What is the role of the Process Control Block (PCB)?
A. Stores the code of the process
B. Maintains information needed to manage the process
C. Keeps track of all files in the system
D. Manages memory allocation
✅ Answer: B. Maintains information needed to manage the process
5. The transition from running to waiting state occurs when:
A. The time slice expires
B. An I/O request is made
C. A process is terminated
D. An interrupt occurs
✅ Answer: B. An I/O request is made
6. What is a zombie process?
A. A process waiting for CPU time
B. A process terminated but not yet cleaned up by its parent
C. A suspended process
D. A process using too much memory
✅ Answer: B. A process terminated but not yet cleaned up by its parent
7. Which system call is used to create a new process in Unix/Linux?
A. exec()
B. create()
C. fork()
D. spawn()
✅ Answer: C. fork()
8. What does the exec() system call do?
A. Terminates the current process
B. Creates a new process
C. Loads a new program into the current process
D. Puts the process to sleep
✅ Answer: C. Loads a new program into the current process
9. What is the parent process?
A. The first process in the system
B. A process that spawns or creates another process
C. A system process
D. A process with the highest priority
✅ Answer: B. A process that spawns or creates another process
10. What is a child process?
A. A process that is currently executing
B. A process created by another process
C. A system process with root access
D. The first process of a user
✅ Answer: B. A process created by another process
11. Which of the following queues is used to store processes that are ready to execute?
A. Wait queue
B. Ready queue
C. Job queue
D. Device queue
✅ Answer: B. Ready queue
12. A process is said to be in a waiting state when:
A. It is executing
B. It is ready to execute
C. It is waiting for some event like I/O to occur
D. It is terminated
✅ Answer: C. It is waiting for some event like I/O to occur
13. Which component is responsible for switching between processes?
A. Memory manager
B. CPU scheduler
C. Device driver
D. File system
✅ Answer: B. CPU scheduler
14. Which system call is used by a process to terminate itself?
A. stop()
B. exit()
C. kill()
D. end()
✅ Answer: B. exit()
15. In a multiprogramming environment, the OS keeps multiple processes in:
A. Main memory
B. Registers
C. Disk
D. Cache
✅ Answer: A. Main memory
CPU Scheduling – MCQs with Answers (OS)
1. What is CPU scheduling?
A. Allocating memory to processes
B. Allocating the CPU to processes in the ready queue
C. Terminating blocked processes
D. Managing I/O devices
✅ Answer: B. Allocating the CPU to processes in the ready queue
2. Which of the following is a non-preemptive scheduling algorithm?
A. Round Robin
B. Priority Scheduling
C. Shortest Job First (SJF)
D. Multilevel Queue
✅ Answer: C. Shortest Job First (SJF)
3. In Round Robin scheduling, each process gets the CPU for a:
A. Random time
B. Time slice or quantum
C. Full execution
D. Priority-based duration
✅ Answer: B. Time slice or quantum
4. Which scheduling algorithm may lead to starvation?
A. FCFS
B. Round Robin
C. SJF
D. Multilevel Feedback Queue
✅ Answer: C. SJF
5. In First-Come, First-Served (FCFS) scheduling:
A. Processes are executed in reverse order of arrival
B. The shortest process is selected first
C. The process that arrives first is served first
D. Processes are scheduled randomly
✅ Answer: C. The process that arrives first is served first
6. Which scheduling algorithm is most suitable for time-sharing systems?
A. SJF
B. FCFS
C. Round Robin
D. Priority Scheduling
✅ Answer: C. Round Robin
7. In Priority Scheduling, if two processes have the same priority, which one is executed
first?
A. The one with the highest CPU burst
B. Randomly chosen
C. The one that arrives first (FCFS tie-breaker)
D. The one with the lowest PID
✅ Answer: C. The one that arrives first (FCFS tie-breaker)
8. Which of the following algorithms minimizes average waiting time the most?
A. FCFS
B. SJF (non-preemptive)
C. Priority
D. Round Robin
✅ Answer: B. SJF (non-preemptive)
9. A disadvantage of FCFS scheduling is:
A. Starvation
B. High complexity
C. Convoy effect (long process delays others)
D. Not fair
✅ Answer: C. Convoy effect (long process delays others)
10. Which of the following is preemptive?
A. FCFS
B. SJF
C. Round Robin
D. All of the above
✅ Answer: C. Round Robin
11. What is aging in CPU scheduling?
A. Giving older processes higher priority to prevent starvation
B. Killing old processes
C. Making old processes wait longer
D. Replacing old processes
✅ Answer: A. Giving older processes higher priority to prevent starvation
12. What does a context switch involve?
A. Changing the priority of a process
B. Moving a process to disk
C. Saving and loading the state of processes
D. Starting a new application
✅ Answer: C. Saving and loading the state of processes
13. In multilevel queue scheduling:
A. All queues are of equal priority
B. Processes can move between queues
C. Each queue has a different scheduling algorithm
D. Only batch processes are allowed
✅ Answer: C. Each queue has a different scheduling algorithm
14. Which of these metrics is important for CPU scheduling?
A. Turnaround time
B. Waiting time
C. Response time
D. All of the above
✅ Answer: D. All of the above
15. The Gantt chart is used for:
A. File system visualization
B. Memory management
C. Visualizing process scheduling and timing
D. Disk scheduling
✅ Answer: C. Visualizing process scheduling and timing
Process Synchronization – MCQs with Answers (OS)
1. What is the goal of process synchronization?
A. To enable multitasking
B. To avoid system crashes
C. To ensure consistent data access among concurrent processes
D. To increase CPU speed
✅ Answer: C. To ensure consistent data access among concurrent processes
2. The critical section problem arises in a system when:
A. Processes run sequentially
B. Two or more processes access shared data concurrently
C. Only one process exists
D. No resources are shared
✅ Answer: B. Two or more processes access shared data concurrently
3. Which of the following is not a requirement for a solution to the critical section
problem?
A. Mutual exclusion
B. Progress
C. Bounded waiting
D. High CPU usage
✅ Answer: D. High CPU usage
4. Which of the following synchronization tools is not typically used in user-level
programming?
A. Semaphore
B. Mutex
C. Monitor
D. Compiler
✅ Answer: D. Compiler
5. A binary semaphore can have values:
A. 0 and 1
B. Any positive integer
C. Only 0
D. True or False
✅ Answer: A. 0 and 1
6. Which of the following is a software-based solution to the critical section problem?
A. Peterson’s Algorithm
B. Test-and-Set
C. Semaphores
D. Spinlocks
✅ Answer: A. Peterson’s Algorithm
7. What does a semaphore use to control access to a shared resource?
A. Condition variable
B. Integer value
C. Memory block
D. Critical section
✅ Answer: B. Integer value
8. What is the main difference between a binary semaphore and a counting semaphore?
A. Binary semaphore has only one process
B. Counting semaphore can count multiple resources
C. Binary semaphore cannot block a process
D. Counting semaphore is used only in real-time OS
✅ Answer: B. Counting semaphore can count multiple resources
9. Which of the following correctly describes a race condition?
A. Processes wait for each other indefinitely
B. Processes execute in sequence
C. Outcome depends on the order of execution of instructions
D. No process enters the critical section
✅ Answer: C. Outcome depends on the order of execution of instructions
10. A monitor is a:
A. Hardware device
B. High-level synchronization construct
C. Binary semaphore
D. System call
✅ Answer: B. High-level synchronization construct
11. The wait() operation on a semaphore:
A. Increments the value
B. Blocks if the value is zero
C. Destroys the semaphore
D. Frees a process
✅ Answer: B. Blocks if the value is zero
12. The signal() operation on a semaphore:
A. Blocks a process
B. Waits for a resource
C. Increments the semaphore value
D. Terminates the process
✅ Answer: C. Increments the semaphore value
13. Which of the following is used to prevent busy waiting?
A. Spinlock
B. Mutex
C. Blocking system calls (like wait())
D. Race condition
✅ Answer: C. Blocking system calls (like wait())
14. In which scenario is busy waiting acceptable?
A. Long-term resource contention
B. When the wait is expected to be short
C. When context switching is preferred
D. For I/O operations
✅ Answer: B. When the wait is expected to be short
15. Which statement about semaphores is true?
A. They are only used in kernel-level programming
B. They provide a way to synchronize access to shared resources
C. They automatically prevent deadlock
D. They are obsolete in modern operating systems
✅ Answer: B. They provide a way to synchronize access to shared resources
Deadlocks in Operating Systems – MCQs with Answers
1. What is a deadlock in an operating system?
A. A process that is running indefinitely
B. A situation where processes wait indefinitely for a resource held by each other
C. A terminated process
D. A hardware failure
✅ Answer: B. A situation where processes wait indefinitely for a resource held by each other
2. Which of the following is NOT one of the necessary conditions for a deadlock to
occur?
A. Mutual exclusion
B. Preemption
C. Hold and wait
D. Circular wait
✅ Answer: B. Preemption
3. How many conditions must be true simultaneously for a deadlock to occur?
A. 2
B. 3
C. 4
D. 5
✅ Answer: C. 4
(These are: Mutual exclusion, Hold and wait, No preemption, Circular wait)
4. In deadlock prevention, which condition is typically avoided?
A. Mutual exclusion
B. Hold and wait
C. No preemption
D. All of the above
✅ Answer: D. All of the above
(Deadlock prevention aims to break at least one of the 4 necessary conditions.)
5. Which of the following algorithms can detect deadlock?
A. Banker's Algorithm
B. Round Robin
C. FIFO
D. Best Fit
✅ Answer: A. Banker's Algorithm
6. What is the role of the Resource Allocation Graph (RAG)?
A. To allocate memory
B. To detect and represent deadlocks
C. To schedule processes
D. To manage virtual memory
✅ Answer: B. To detect and represent deadlocks
7. In a Resource Allocation Graph, what does a cycle indicate?
A. No process is using a resource
B. Possibility of deadlock (in case of multiple instances)
C. CPU is idle
D. Memory leak
✅ Answer: B. Possibility of deadlock (if resource has multiple instances)
8. What is deadlock avoidance?
A. Killing all processes
B. Allocating maximum resources to all processes
C. Allocating resources only if the system remains in a safe state
D. Ignoring deadlocks
✅ Answer: C. Allocating resources only if the system remains in a safe state
9. What is a "safe state" in deadlock avoidance?
A. A state with no processes
B. A state where the system can allocate resources without deadlock
C. A state with no resource usage
D. A state where all processes are blocked
✅ Answer: B. A state where the system can allocate resources without deadlock
10. Which of the following strategies is not used for handling deadlocks?
A. Deadlock prevention
B. Deadlock detection and recovery
C. Deadlock avoidance
D. Deadlock replication
✅ Answer: D. Deadlock replication
11. The term "no preemption" means:
A. A resource can be forcibly taken from a process
B. A resource cannot be forcibly removed from a process
C. A process can be preempted
D. CPU scheduling must follow priority
✅ Answer: B. A resource cannot be forcibly removed from a process
12. Which of the following is true about the Banker's Algorithm?
A. It detects deadlocks
B. It avoids deadlocks
C. It prevents deadlocks
D. It recovers from deadlocks
✅ Answer: B. It avoids deadlocks
13. In the Resource Allocation Graph (RAG), what does a request edge look like?
A. Dashed line from resource to process
B. Solid arrow from process to resource
C. Dotted line from process to CPU
D. Circle inside square
✅ Answer: B. Solid arrow from process to resource
14. One simple way to recover from a deadlock is:
A. Ignore it
B. Restart the system
C. Allocate all resources to one process
D. Preallocate resources statically
✅ Answer: B. Restart the system
15. In which scenario is deadlock more likely to occur?
A. Single-threaded systems
B. Systems with multiple resource allocation and poor synchronization
C. Batch processing
D. Systems with preemptive kernels only
✅ Answer: B. Systems with multiple resource allocation and poor synchronization
Memory Management in OS – MCQs with Answers
1. What is the main function of memory management in an operating system?
A. Managing files on disk
B. Allocating CPU time
C. Managing the computer's memory resources
D. Scheduling processes
✅ Answer: C. Managing the computer's memory resources
2. Which part of memory is directly accessible by the CPU?
A. Virtual Memory
B. Cache
C. Main Memory (RAM)
D. Secondary Storage
✅ Answer: C. Main Memory (RAM)
3. In paging, a process is divided into:
A. Segments
B. Blocks
C. Pages
D. Frames
✅ Answer: C. Pages
4. What is internal fragmentation?
A. Unused space between files
B. Unused space inside allocated memory blocks
C. Used space in disk blocks
D. Overlapping of data
✅ Answer: B. Unused space inside allocated memory blocks
5. External fragmentation occurs when:
A. Memory is too small
B. There’s enough total memory but not contiguous blocks
C. Files are deleted
D. Paging is not used
✅ Answer: B. There’s enough total memory but not contiguous blocks
6. Which memory allocation technique suffers from external fragmentation?
A. Paging
B. Segmentation
C. Contiguous memory allocation
D. None
✅ Answer: C. Contiguous memory allocation
7. What is virtual memory?
A. Memory on the GPU
B. Secondary memory used as an extension of RAM
C. Cache memory
D. Read-only memory
✅ Answer: B. Secondary memory used as an extension of RAM
8. Which of the following uses a page table?
A. Segmentation
B. Paging
C. Contiguous Allocation
D. Demand Paging
✅ Answer: B. Paging
9. The role of the MMU (Memory Management Unit) is to:
A. Manage cache
B. Translate virtual addresses to physical addresses
C. Control disk operations
D. Schedule processes
✅ Answer: B. Translate virtual addresses to physical addresses
10. In paging, the page table is used to:
A. Store processes
B. Store instructions
C. Map logical to physical addresses
D. Store file paths
✅ Answer: C. Map logical to physical addresses
11. A page fault occurs when:
A. A page is found in RAM
B. A page is not found in memory
C. A process completes execution
D. A page is deleted
✅ Answer: B. A page is not found in memory
12. Which memory management scheme does NOT support dynamic address
translation?
A. Paging
B. Segmentation
C. Contiguous Allocation
D. Demand Paging
✅ Answer: C. Contiguous Allocation
13. What is a frame in paging?
A. A unit of CPU time
B. A physical block of memory
C. A logical block
D. A memory hole
✅ Answer: B. A physical block of memory
14. Which of these is a disadvantage of paging?
A. No memory protection
B. Complex memory management
C. Internal fragmentation
D. External fragmentation
✅ Answer: C. Internal fragmentation
15. What is the main advantage of virtual memory?
A. Reduces memory speed
B. Eliminates secondary storage
C. Allows larger programs than physical memory
D. Increases fragmentation
✅ Answer: C. Allows larger programs than physical memory
File System Interface, I/O Systems & Assemblers – MCQs with
Answers (OS)
🗂️A. File System Interface
1. What is the main purpose of a file system?
A. Manage CPU usage
B. Manage memory
C. Store and organize files
D. Execute instructions
✅ Answer: C. Store and organize files
2. Which of the following is a valid file operation?
A. Create
B. Read
C. Write
D. All of the above
✅ Answer: D. All of the above
3. File extensions help the OS to:
A. Compress files
B. Identify the file type
C. Increase memory size
D. Encrypt the file
✅ Answer: B. Identify the file type
4. What is the directory structure that allows sharing of files among users?
A. Single-level
B. Two-level
C. Tree-structured
D. Acyclic graph
✅ Answer: D. Acyclic graph
5. Which allocation method allows non-contiguous memory blocks?
A. Contiguous allocation
B. Linked allocation
C. Indexed allocation
D. Both B and C
✅ Answer: D. Both B and C
💽 B. I/O Systems
6. What does I/O stand for in Operating Systems?
A. Input Output
B. Inside Outside
C. Initial Operation
D. Input Only
✅ Answer: A. Input Output
7. Which of the following is an I/O control method?
A. Programmed I/O
B. Interrupt-driven I/O
C. DMA (Direct Memory Access)
D. All of the above
✅ Answer: D. All of the above
8. What is the role of device drivers in an I/O system?
A. Manage the CPU
B. Allow user to type
C. Provide a software interface to hardware devices
D. Format disks
✅ Answer: C. Provide a software interface to hardware devices
9. Which I/O technique requires the CPU to wait during data transfer?
A. DMA
B. Programmed I/O
C. Interrupt-driven I/O
D. Spooling
✅ Answer: B. Programmed I/O
10. What is spooling in an I/O system?
A. Sequential paging
B. Simultaneous Printing On Line
C. Storing data temporarily for slow devices like printers
D. Speed boosting technique
✅ Answer: C. Storing data temporarily for slow devices like printers
🛠️C. Assemblers
11. What is the main function of an assembler?
A. Convert source code to bytecode
B. Convert assembly code to machine code
C. Convert high-level language to assembly
D. Interpret Python code
✅ Answer: B. Convert assembly code to machine code
12. Assembly language is a:
A. High-level language
B. Low-level language
C. Machine-independent language
D. Web-based language
✅ Answer: B. Low-level language
13. An assembler converts a program written in:
A. Binary to Hex
B. High-level to C
C. Assembly to Machine Code
D. Pseudocode to Assembly
✅ Answer: C. Assembly to Machine Code
14. Which of the following is NOT true about assemblers?
A. They are OS-level programs
B. They handle symbolic names
C. They require compilers to run
D. They generate object code
✅ Answer: C. They require compilers to run
15. What is a two-pass assembler?
A. Runs twice for speed
B. Scans the code twice for symbol resolution and code generation
C. Converts high-level code
D. Encrypts source files
✅ Answer: B. Scans the code twice for symbol resolution and code generation
Macros in Operating Systems / Assemblers – MCQs with Answers
✅ 1. What is a macro?
A. A type of compiler
B. A small program inside an operating system
C. A sequence of instructions represented by a single name
D. A type of file system
✅ Answer: C. A sequence of instructions represented by a single name
Explanation: A macro allows the programmer to define a series of instructions that can be
inserted multiple times using a single command.
✅ 2. Where are macros typically used in system software?
A. Operating system kernel
B. Assemblers and compilers
C. BIOS firmware
D. File systems
✅ Answer: B. Assemblers and compilers
Explanation: Macros are extensively used in assemblers for code reuse and simplification.
✅ 3. What is the main advantage of using macros?
A. Reduced memory usage
B. Faster disk access
C. Code reusability and simplification
D. Hardware abstraction
✅ Answer: C. Code reusability and simplification
Explanation: Macros reduce duplication of code and make the program easier to manage.
✅ 4. Macros are expanded:
A. At runtime
B. During linking
C. During macro processing phase before assembly
D. After execution
✅ Answer: C. During macro processing phase before assembly
Explanation: Macro expansion happens before actual assembly takes place.
✅ 5. What is macro expansion?
A. Linking macros to system libraries
B. Converting macros into high-level code
C. Replacing macro calls with the actual instructions
D. Compressing macros
✅ Answer: C. Replacing macro calls with the actual instructions
Explanation: During macro expansion, the macro name is replaced with its corresponding
block of instructions.
✅ 6. Which of the following best describes a macro processor?
A. It converts high-level code to machine code
B. It replaces macro invocations with corresponding code
C. It schedules CPU tasks
D. It manages memory
✅ Answer: B. It replaces macro invocations with corresponding code
Explanation: Macro processors handle the expansion of macros.
✅ 7. A macro definition begins with which assembler directive?
A. .end
B. macro
C. define
D. start
✅ Answer: B. macro
Explanation: Most assemblers use macro to indicate the beginning of a macro definition.
✅ 8. Which of the following can macros NOT do compared to subroutines?
A. Accept parameters
B. Be reused
C. Save memory
D. Perform complex tasks
✅ Answer: C. Save memory
Explanation: Macros increase code size because each use inserts code, unlike subroutines
which use a single memory block.
✅ 9. What does the term "nested macro" mean?
A. Macros used inside functions
B. Macros calling other macros
C. Macros that compile themselves
D. Macros for memory management
✅ Answer: B. Macros calling other macros
Explanation: Nesting occurs when one macro includes a call to another macro within it.
✅ 10. A key disadvantage of using macros is:
A. Decreased readability
B. Increased memory efficiency
C. Reduced code reusability
D. Code bloat due to expansion
✅ Answer: D. Code bloat due to expansion
Explanation: Each macro use is expanded into full code, which can lead to large binaries.
Macro Processors in OS – MCQs with Answers
✅ 1. What is the function of a macro processor in an operating system or
assembler?
A. Executes system calls
B. Compiles high-level code
C. Expands macros into source code before assembly
D. Manages disk memory
✅ Answer: C. Expands macros into source code before assembly
Explanation: Macro processors replace macro invocations with corresponding sequences of
source instructions.
✅ 2. When is a macro processor typically invoked during compilation or
assembly?
A. After linking
B. After execution
C. Before actual assembly
D. During runtime
✅ Answer: C. Before actual assembly
Explanation: Macro processing occurs as a pre-processing step before the assembler
translates code.
✅ 3. A macro definition generally starts with which keyword in assembly
language?
A. START
B. DEFINE
C. MACRO
D. PROC
✅ Answer: C. MACRO
✅ 4. Which of the following is NOT a function of the macro processor?
A. Handling conditional macro expansion
B. Expanding nested macros
C. Allocating memory dynamically
D. Parameter substitution
✅ Answer: C. Allocating memory dynamically
Explanation: Macro processors do not manage memory; they handle code expansion and
substitution only.
✅ 5. What is a positional parameter in a macro definition?
A. A keyword argument
B. A system-defined constant
C. An argument referenced by its order
D. A memory address
✅ Answer: C. An argument referenced by its order
Explanation: Positional parameters are accessed based on their order of appearance.
✅ 6. Which of the following is a key advantage of using macros?
A. Code becomes faster to execute
B. Reduces compiled file size
C. Enhances code reusability and reduces repetition
D. Avoids need for a processor
✅ Answer: C. Enhances code reusability and reduces repetition
✅ 7. Which table stores macro names and their definitions during macro
processing?
A. Macro Expansion Table (MET)
B. Macro Definition Table (MDT)
C. Macro Instruction Table (MIT)
D. Parameter Table
✅ Answer: B. Macro Definition Table (MDT)
✅ 8. The table that holds the names of macros and pointers to their definitions
is:
A. Parameter Table
B. Macro Name Table (MNT)
C. Symbol Table
D. Macro Execution Table
✅ Answer: B. Macro Name Table (MNT)
✅ 9. Which table maps actual parameters to formal parameters during macro
expansion?
A. MDT
B. MNT
C. Argument List Array (ALA)
D. Expansion Table
✅ Answer: C. Argument List Array (ALA)
✅ 10. What happens during the macro expansion phase?
A. The assembler translates code to object code
B. The loader links files
C. Macro calls are replaced with corresponding code
D. The compiler executes the program
✅ Answer: C. Macro calls are replaced with corresponding code
✅ 11. Which of the following is a disadvantage of macros compared to
subroutines?
A. Slower execution
B. Increases memory usage due to repeated code
C. Can't handle parameters
D. Harder to debug
✅ Answer: B. Increases memory usage due to repeated code
✅ 12. What is the role of the pass 1 in a two-pass macro processor?
A. Executes macro code
B. Performs macro expansion
C. Stores macro definitions into tables
D. Generates object code
✅ Answer: C. Stores macro definitions into tables
✅ 13. Macro processors are often embedded in:
A. Loaders
B. Assemblers
C. Linkers
D. Debuggers
✅ Answer: B. Assemblers
✅ 14. A conditional macro expansion allows the macro to:
A. Loop through all instructions
B. Expand only if certain conditions are met
C. Be skipped during execution
D. Reduce code size
✅ Answer: B. Expand only if certain conditions are met
✅ 15. Nested macro calls mean:
A. Macros are written using high-level language
B. One macro calls another macro inside its body
C. Macros are not expanded
D. Macros are linked to compilers
✅ Answer: B. One macro calls another macro inside its body
Linkers in Operating Systems – MCQs with Answers
✅ 1. What is the role of a linker in a system?
A. To convert assembly code to machine code
B. To execute the program
C. To combine object modules into a single executable
D. To allocate memory to processes
✅ Answer: C. To combine object modules into a single executable
Explanation: A linker resolves addresses and links multiple object files into one final
executable.
✅ 2. Which of the following inputs does a linker use?
A. Source code
B. Object code
C. Machine code
D. Assembly code
✅ Answer: B. Object code
Explanation: The linker takes object files (.obj/.o) produced by the compiler or assembler.
✅ 3. A linker combines:
A. Source files
B. Header files
C. Object modules
D. Compilers
✅ Answer: C. Object modules
✅ 4. Which of the following does NOT happen in linking?
A. Address resolution
B. Symbol resolution
C. Syntax checking
D. Code relocation
✅ Answer: C. Syntax checking
Explanation: Syntax checking is done at compile time, not during linking.
✅ 5. What is static linking?
A. Linking done at runtime
B. Linking done during program execution
C. Linking done before execution and added to the executable
D. Linking via network
✅ Answer: C. Linking done before execution and added to the executable
✅ 6. What is dynamic linking?
A. Linking at compile-time
B. Linking done only once
C. Linking done during program execution
D. Linking during booting
✅ Answer: C. Linking done during program execution
Explanation: Dynamic linking uses shared libraries and resolves symbols at runtime.
✅ 7. What is the symbol table in a linker used for?
A. To store executable files
B. To map source lines to errors
C. To match external and internal references to memory addresses
D. To hold user inputs
✅ Answer: C. To match external and internal references to memory addresses
✅ 8. A linker resolves:
A. Syntax errors
B. Logical errors
C. External symbols and addresses
D. Compilation errors
✅ Answer: C. External symbols and addresses
✅ 9. The linker uses which of the following tables to perform address
relocation?
A. Export Table
B. Relocation Table
C. Symbol Table
D. Object Table
✅ Answer: B. Relocation Table
Explanation: The relocation table tells the linker where address adjustments are needed.
✅ 10. A relocatable program is:
A. One that can't be moved
B. One that executes directly from disk
C. One that can be loaded at any memory address
D. A backup file
✅ Answer: C. One that can be loaded at any memory address
✅ 11. What does a linking loader do?
A. Loads only data into memory
B. Loads and links all object modules in memory
C. Checks syntax
D. Compresses the executable
✅ Answer: B. Loads and links all object modules in memory
✅ 12. In static linking, the linked code becomes part of:
A. The kernel
B. The executable file
C. The source code
D. The compiler
✅ Answer: B. The executable file
✅ 13. In dynamic linking, shared libraries are usually loaded via:
A. The linker
B. The file system
C. The loader during program execution
D. The compiler
✅ Answer: C. The loader during program execution
✅ 14. Linking multiple object files helps in:
A. Reducing memory
B. Code modularity and reuse
C. Removing errors
D. Improving compilation
✅ Answer: B. Code modularity and reuse
✅ 15. Which tool typically invokes the linker automatically?
A. Assembler
B. Debugger
C. Compiler
D. Scheduler
✅ Answer: C. Compiler
Explanation: Most compilers automatically invoke the linker after compilation is done.
Distributed Systems Communication – MCQs with Answers (OS)
✅ 1. In a distributed system, what is the primary purpose of communication?
A. User interface rendering
B. Sharing hardware
C. Resource and information exchange between nodes
D. Installing software
✅ Answer: C. Resource and information exchange between nodes
Explanation: Communication allows distributed components to coordinate and share
data/resources.
✅ 2. Which of the following is commonly used for communication in
distributed systems?
A. Sockets
B. APIs
C. Shared memory
D. Pipelines
✅ Answer: A. Sockets
Explanation: Sockets are widely used for network communication in distributed systems.
✅ 3. RPC stands for:
A. Remote Port Communication
B. Remote Procedure Call
C. Remote Processing Channel
D. Rapid Protocol Communication
✅ Answer: B. Remote Procedure Call
Explanation: RPC allows a program to call a procedure on a remote machine as if it were
local.
✅ 4. What is message passing in distributed systems?
A. File system sharing
B. Memory swapping
C. Sending and receiving data between processes
D. Static linking of code
✅ Answer: C. Sending and receiving data between processes
✅ 5. Which of the following models does NOT support direct communication
between distributed nodes?
A. RPC
B. Message Queues
C. Shared Memory
D. Sockets
✅ Answer: C. Shared Memory
Explanation: Shared memory is primarily for local communication, not across distributed
systems.
✅ 6. Which protocol is mostly used for reliable communication in distributed
systems?
A. UDP
B. ICMP
C. TCP
D. FTP
✅ Answer: C. TCP
Explanation: TCP provides reliable, ordered, and error-checked delivery of data.
✅ 7. What is marshalling in the context of distributed systems?
A. Encryption of messages
B. Compressing code
C. Packing and unpacking data for transmission
D. Allocating memory
✅ Answer: C. Packing and unpacking data for transmission
✅ 8. In distributed systems, latency refers to:
A. CPU idle time
B. Delay in message delivery
C. Storage space left
D. Number of servers
✅ Answer: B. Delay in message delivery
✅ 9. What is the main drawback of synchronous communication in distributed
systems?
A. Messages can't be encrypted
B. High resource utilization
C. Sender must wait for receiver
D. No security
✅ Answer: C. Sender must wait for receiver
Explanation: Synchronous communication blocks the sender until the receiver acknowledges.
✅ 10. Asynchronous communication allows:
A. No communication at all
B. Simultaneous message transmission and reception
C. Communication without blocking
D. Only unidirectional communication
✅ Answer: C. Communication without blocking
✅ 11. Which of these is NOT a communication issue in distributed systems?
A. Message loss
B. Deadlock
C. Naming
D. Local variable scoping
✅ Answer: D. Local variable scoping
✅ 12. The concept of naming in communication refers to:
A. Naming users
B. Identifying resources or services in a distributed environment
C. Naming variables
D. Naming logs
✅ Answer: B. Identifying resources or services in a distributed environment
✅ 13. What is group communication in distributed systems?
A. Sharing RAM
B. Multicast communication with a set of processes
C. Sending emails
D. Thread creation
✅ Answer: B. Multicast communication with a set of processes
✅ 14. Which mechanism ensures order of messages in distributed systems?
A. Load balancer
B. Logical clocks
C. DNS
D. IP address allocation
✅ Answer: B. Logical clocks
Explanation: Logical clocks (e.g., Lamport clocks) help in ordering events/messages.
✅ 15. Which of the following is a communication middleware in distributed
systems?
A. SMTP
B. Java RMI
C. SSD
D. RAM
✅ Answer: B. Java RMI
Explanation: Java RMI is a middleware that enables invoking methods across JVMs.
Synchronization in Operating Systems – MCQs with Answers
✅ 1. What is process synchronization?
A. Running multiple processes simultaneously
B. Coordinating processes to ensure correct sequence of execution
C. Terminating processes
D. Allocating memory to processes
✅ Answer: B. Coordinating processes to ensure correct sequence of execution
Explanation: Synchronization controls the order in which processes access shared resources.
✅ 2. Which of the following problems is solved by synchronization?
A. Deadlock
B. Race condition
C. Memory leak
D. Process scheduling
✅ Answer: B. Race condition
Explanation: Synchronization prevents race conditions where multiple processes access
shared data simultaneously.
✅ 3. What is a critical section?
A. Part of code where processes can execute independently
B. Part of code where processes access shared resources
C. Code that causes errors
D. Kernel code
✅ Answer: B. Part of code where processes access shared resources
Explanation: Critical sections are parts of code that must not be executed by more than one
process at a time.
✅ 4. Which of the following is NOT a requirement for proper
synchronization?
A. Mutual exclusion
B. Progress
C. Bounded waiting
D. Infinite waiting
✅ Answer: D. Infinite waiting
Explanation: Infinite waiting (starvation) is undesirable and must be avoided.
✅ 5. Which synchronization mechanism uses busy waiting?
A. Semaphores
B. Mutex Locks
C. Monitors
D. All of the above
✅ Answer: A. Semaphores
Explanation: Semaphores implemented with busy waiting cause processes to loop while
waiting.
✅ 6. What does a semaphore do?
A. Controls access to shared resources
B. Schedules CPU tasks
C. Allocates memory
D. Terminates processes
✅ Answer: A. Controls access to shared resources
Explanation: Semaphores are integer variables used to control process synchronization.
✅ 7. The value of a binary semaphore is:
A. Any integer
B. Only 0 or 1
C. Between -1 and 1
D. Always positive
✅ Answer: B. Only 0 or 1
Explanation: Binary semaphores act like mutex locks, allowing only two states.
✅ 8. Which operation decreases the semaphore value and may cause blocking?
A. signal()
B. wait()
C. unlock()
D. start()
✅ Answer: B. wait()
Explanation: wait() decrements the semaphore and blocks if value is zero.
✅ 9. The Producer-Consumer problem is an example of:
A. Deadlock
B. Process synchronization problem
C. Memory management issue
D. Scheduling problem
✅ Answer: B. Process synchronization problem
✅ 10. What is deadlock in synchronization?
A. Processes working without interruption
B. A situation where processes wait indefinitely for resources
C. Successful completion of processes
D. Memory allocation error
✅ Answer: B. A situation where processes wait indefinitely for resources
✅ 11. Which of the following is a solution to the critical section problem?
A. Disabling interrupts
B. Using mutex locks
C. Using semaphores
D. All of the above
✅ Answer: D. All of the above
✅ 12. What is the main disadvantage of busy waiting?
A. Memory wastage
B. CPU wastage
C. I/O overhead
D. Deadlock
✅ Answer: B. CPU wastage
Explanation: Busy waiting wastes CPU cycles as the process repeatedly checks for a
condition.
✅ 13. Which synchronization technique allows only one process to enter the
critical section at a time?
A. Semaphore
B. Mutex
C. Monitor
D. All of the above
✅ Answer: D. All of the above
Explanation: All these techniques enforce mutual exclusion.
✅ 14. What is the purpose of the wait() and signal() operations in semaphores?
A. wait() signals process termination, signal() restarts process
B. wait() acquires the resource, signal() releases the resource
C. wait() and signal() terminate processes
D. None of the above
✅ Answer: B. wait() acquires the resource, signal() releases the resource
✅ 15. A monitor is:
A. A hardware device
B. A high-level synchronization construct that provides mutual exclusion
C. A type of semaphore
D. A process scheduler
✅ Answer: B. A high-level synchronization construct that provides mutual exclusion
Deadlocks in Operating Systems – MCQs with Answers
✅ 1. What is a deadlock in operating systems?
A. When a process terminates normally
B. When processes are stuck waiting indefinitely for resources held by each other
C. When memory is full
D. When CPU scheduling is preemptive
✅ Answer: B. When processes are stuck waiting indefinitely for resources held by each other
Explanation: Deadlock occurs when a set of processes wait forever because each is holding a
resource and waiting for another.
✅ 2. Which of the following is NOT a necessary condition for deadlock?
A. Mutual exclusion
B. Hold and wait
C. Preemption
D. Circular wait
✅ Answer: C. Preemption
Explanation: Deadlock requires no preemption; preemption can help prevent deadlocks.
✅ 3. The deadlock condition “hold and wait” means:
A. A process holds resources while waiting for others
B. A process releases all resources before requesting new ones
C. Processes are terminated immediately
D. Resources are shared among processes
✅ Answer: A. A process holds resources while waiting for others
✅ 4. Which strategy can be used to avoid deadlocks?
A. Mutual exclusion
B. Banker’s algorithm
C. Circular wait
D. Hold and wait
✅ Answer: B. Banker’s algorithm
Explanation: Banker’s algorithm helps avoid unsafe states that could lead to deadlocks.
✅ 5. What is deadlock detection?
A. Preventing deadlocks from occurring
B. Allowing deadlocks to happen and then identifying them
C. Ignoring deadlocks
D. Terminating all processes
✅ Answer: B. Allowing deadlocks to happen and then identifying them
✅ 6. What happens during deadlock recovery?
A. Processes run faster
B. Resources are preempted or processes are terminated to break deadlock
C. Deadlocks are ignored
D. CPU scheduling is changed
✅ Answer: B. Resources are preempted or processes are terminated to break deadlock
✅ 7. Which of these data structures is used in deadlock detection algorithms?
A. Resource Allocation Graph (RAG)
B. Linked list
C. Stack
D. Queue
✅ Answer: A. Resource Allocation Graph (RAG)
Explanation: RAGs show process-resource relationships and help detect cycles indicating
deadlock.
✅ 8. What does a cycle in a Resource Allocation Graph signify?
A. Normal execution
B. Deadlock or potential deadlock
C. Free resources
D. Completed processes
✅ Answer: B. Deadlock or potential deadlock
✅ 9. Which of the following can be used to prevent deadlocks?
A. Remove mutual exclusion
B. Allow circular wait
C. Allow hold and wait
D. Ignore deadlock conditions
✅ Answer: A. Remove mutual exclusion
✅ 10. What is preemption in the context of deadlocks?
A. Forcing a process to release a resource
B. Allocating resources
C. Process termination
D. Deadlock detection
✅ Answer: A. Forcing a process to release a resource
✅ 11. Which deadlock handling method is most suitable for systems with rare
deadlocks?
A. Deadlock prevention
B. Deadlock avoidance
C. Deadlock detection and recovery
D. Ignore deadlock
✅ Answer: C. Deadlock detection and recovery
✅ 12. The Banker’s algorithm is an example of:
A. Deadlock detection
B. Deadlock prevention
C. Deadlock avoidance
D. Deadlock recovery
✅ Answer: C. Deadlock avoidance
✅ 13. Which condition can be eliminated by requiring processes to request all
needed resources at once?
A. Circular wait
B. Mutual exclusion
C. Hold and wait
D. No preemption
✅ Answer: C. Hold and wait
✅ 14. Deadlocks are a problem primarily in which type of resource allocation?
A. Preemptible resources
B. Non-preemptible resources
C. Read-only resources
D. Virtual memory
✅ Answer: B. Non-preemptible resources
✅ 15. In deadlock recovery, which is NOT a common approach?
A. Process termination
B. Resource preemption
C. Process suspension
D. Increasing process priority
✅ Answer: D. Increasing process priority
File Systems in Operating Systems – MCQs with Answers
✅ 1. What is a file system?
A. A program to edit files
B. A method to store and organize files on a storage device
C. A hardware device
D. A type of operating system
✅ Answer: B. A method to store and organize files on a storage device
Explanation: File system manages how data is stored, named, and accessed on disks.
✅ 2. Which of the following is NOT a file attribute?
A. Name
B. Size
C. Creation date
D. CPU usage
✅ Answer: D. CPU usage
Explanation: CPU usage is not related to file attributes.
✅ 3. What does the file pointer indicate?
A. Beginning of the file
B. Current position for reading or writing in the file
C. End of file
D. File size
✅ Answer: B. Current position for reading or writing in the file
✅ 4. Which of the following is NOT a file access method?
A. Sequential access
B. Direct access
C. Random access
D. Logical access
✅ Answer: D. Logical access
✅ 5. What is a directory in a file system?
A. A file type
B. A special file containing information about other files
C. A device driver
D. A program
✅ Answer: B. A special file containing information about other files
✅ 6. Which file system structure allows files to be organized in a tree
hierarchy?
A. Single-level directory
B. Two-level directory
C. Hierarchical directory
D. Flat directory
✅ Answer: C. Hierarchical directory
✅ 7. What is the purpose of a file allocation table (FAT)?
A. Store file content
B. Manage free disk space
C. Map file blocks to physical locations on disk
D. Store user passwords
✅ Answer: C. Map file blocks to physical locations on disk
✅ 8. Which file allocation method stores file blocks sequentially?
A. Contiguous allocation
B. Linked allocation
C. Indexed allocation
D. Cluster allocation
✅ Answer: A. Contiguous allocation
✅ 9. What is a major disadvantage of contiguous allocation?
A. Fragmentation
B. Slow access
C. Requires extra pointers
D. Difficult to implement
✅ Answer: A. Fragmentation
Explanation: Contiguous allocation causes external fragmentation.
✅ 10. Which allocation method uses pointers to link file blocks?
A. Contiguous
B. Linked
C. Indexed
D. Sequential
✅ Answer: B. Linked allocation
✅ 11. What is the main advantage of indexed allocation?
A. Supports direct access
B. Simple implementation
C. No fragmentation
D. Efficient for sequential access only
✅ Answer: A. Supports direct access
✅ 12. What does the command ‘chmod’ do in Unix/Linux?
A. Change file ownership
B. Change file permissions
C. Delete files
D. Copy files
✅ Answer: B. Change file permissions
✅ 13. What is the purpose of a file descriptor?
A. Describe file contents
B. Represent an open file for a process
C. Store file name
D. Describe file permissions
✅ Answer: B. Represent an open file for a process
✅ 14. Which of the following is a special file type?
A. Regular file
B. Directory file
C. Device file
D. Executable file
✅ Answer: C. Device file
✅ 15. Inodes are used in which file system?
A. FAT
B. NTFS
C. Unix File System (UFS)
D. exFAT
✅ Answer: C. Unix File System (UFS)
Explanation: Inodes store metadata about files in Unix-like systems.
Shared Memory & Unix Utilities – MCQs with Answers
Shared Memory MCQs
✅ 1. What is shared memory in operating systems?
A. Memory that can only be accessed by one process at a time
B. Memory shared between multiple processes for communication
C. Memory used for file storage
D. Cache memory
✅ Answer: B. Memory shared between multiple processes for communication
Explanation: Shared memory is a method where multiple processes access common memory
for faster inter-process communication (IPC).
✅ 2. Which of the following is NOT a characteristic of shared memory?
A. Fast communication
B. Requires synchronization mechanisms
C. Data is copied between processes
D. Can be used for IPC
✅ Answer: C. Data is copied between processes
Explanation: In shared memory, data is accessed directly, not copied.
✅ 3. Which system call in Unix is used to create a shared memory segment?
A. shmget()
B. fork()
C. exec()
D. mmap()
✅ Answer: A. shmget()
✅ 4. Which system call attaches a shared memory segment to the process's
address space?
A. shmctl()
B. shmat()
C. shmdt()
D. shmget()
✅ Answer: B. shmat()
✅ 5. How is synchronization usually achieved when using shared memory?
A. Using semaphores or mutexes
B. Using file locks
C. Using pipes
D. No synchronization is needed
✅ Answer: A. Using semaphores or mutexes
Unix Utilities MCQs
✅ 6. Which Unix command is used to display the current directory?
A. ls
B. pwd
C. cd
D. mkdir
✅ Answer: B. pwd
✅ 7. What does the Unix command ‘grep’ do?
A. Copies files
B. Searches for a pattern in files
C. Lists files in a directory
D. Changes file permissions
✅ Answer: B. Searches for a pattern in files
✅ 8. Which Unix utility is used to display the contents of a file one screen at a
time?
A. cat
B. more
C. ls
D. mv
✅ Answer: B. more
✅ 9. What does the ‘chmod’ command do in Unix?
A. Changes file ownership
B. Changes file permissions
C. Moves files
D. Copies files
✅ Answer: B. Changes file permissions
✅ 10. Which command is used to terminate a process in Unix?
A. kill
B. stop
C. end
D. halt
✅ Answer: A. kill
✅ 11. The ‘ps’ command in Unix is used to:
A. Display disk usage
B. Show currently running processes
C. Print file contents
D. Change directories
✅ Answer: B. Show currently running processes
✅ 12. Which command creates a new directory in Unix?
A. mkdir
B. rmdir
C. touch
D. newdir
✅ Answer: A. mkdir
✅ 13. What is the function of the ‘tail’ command?
A. Displays the first lines of a file
B. Displays the last lines of a file
C. Deletes files
D. Moves files
✅ Answer: B. Displays the last lines of a file
✅ 14. Which command displays the manual pages of other commands in Unix?
A. man
B. help
C. info
D. doc
✅ Answer: A. man
✅ 15. Which Unix utility can be used to schedule a command to run at a later
time?
A. cron
B. at
C. batch
D. schedule
✅ Answer: B. at
Problem Solving Approaches in Unix – MCQs with Answers
✅ 1. What is the primary method of problem solving in Unix?
A. Graphical User Interface
B. Command-line interface with utilities and shell scripting
C. Point-and-click menus
D. Automated AI tools
✅ Answer: B. Command-line interface with utilities and shell scripting
Explanation: Unix relies heavily on CLI tools and scripting for solving problems efficiently.
✅ 2. Which Unix feature allows combining multiple commands to perform
complex tasks?
A. Pipes (|)
B. File permissions
C. Cron jobs
D. Disk quotas
✅ Answer: A. Pipes (|)
Explanation: Pipes connect output of one command as input to another, enabling modular
problem solving.
✅ 3. What is the purpose of shell scripting in Unix?
A. Running GUI applications
B. Automating repetitive tasks and problem solving
C. Formatting disks
D. Managing users
✅ Answer: B. Automating repetitive tasks and problem solving
✅ 4. Which of the following is a Unix text-processing utility useful in problem
solving?
A. grep
B. chmod
C. ps
D. kill
✅ Answer: A. grep
Explanation: grep searches for patterns in files, aiding in data filtering and problem analysis.
✅ 5. How do Unix users debug scripts or commands?
A. Using a debugger like gdb
B. Adding echo statements or using set -x in shell scripts
C. Using GUI tools
D. Rebooting the system
✅ Answer: B. Adding echo statements or using set -x in shell scripts
✅ 6. Which command shows currently running processes for problem
analysis?
A. ls
B. ps
C. mkdir
D. cd
✅ Answer: B. ps
✅ 7. What does the kill command do in Unix?
A. Terminates a process by sending signals
B. Deletes files
C. Lists processes
D. Changes file permissions
✅ Answer: A. Terminates a process by sending signals
✅ 8. What is the function of the awk utility in Unix?
A. File copying
B. Pattern scanning and processing for problem solving
C. Directory management
D. Scheduling jobs
✅ Answer: B. Pattern scanning and processing for problem solving
✅ 9. Which of the following is NOT a common problem-solving approach in
Unix?
A. Using multiple small utilities combined with pipes
B. Writing shell scripts for automation
C. Running a single large monolithic program
D. Using text processing tools like sed and awk
✅ Answer: C. Running a single large monolithic program
✅ 10. How can users view system logs for troubleshooting in Unix?
A. Using cat or tail commands on /var/log files
B. Running format command
C. Editing /etc/passwd
D. Using chmod
✅ Answer: A. Using cat or tail commands on /var/log files
✅ 11. Which command is used to schedule repetitive problem-solving tasks in
Unix?
A. crontab
B. ls
C. mv
D. chmod
✅ Answer: A. crontab
✅ 12. What is the benefit of modularity in Unix problem solving?
A. Easier GUI interaction
B. Combining simple tools to perform complex operations
C. Reduced security
D. Faster boot times
✅ Answer: B. Combining simple tools to perform complex operations
✅ 13. How does Unix handle error messages to assist in problem solving?
A. Displays them on the console or redirects to error files
B. Ignores errors silently
C. Automatically fixes errors
D. Reboots the system
✅ Answer: A. Displays them on the console or redirects to error files
✅ 14. Which Unix utility is used for interactive text editing during problem
solving?
A. vim or nano
B. rm
C. kill
D. ls
✅ Answer: A. vim or nano
✅ 15. What is the role of environment variables in Unix problem solving?
A. Store system logs
B. Customize user environment to simplify tasks
C. Allocate memory
D. Manage users
✅ Answer: B. Customize user environment to simplify tasks
Unix Internals – MCQs with Answers
✅ 1. What is the core of the Unix operating system called?
A. Shell
B. Kernel
C. File system
D. User interface
✅ Answer: B. Kernel
Explanation: The kernel is the central part managing hardware and system resources.
✅ 2. Which part of Unix handles system calls?
A. Shell
B. Kernel
C. File system
D. User programs
✅ Answer: B. Kernel
✅ 3. Which structure in Unix stores information about an open file?
A. Inode
B. File descriptor
C. Directory entry
D. Superblock
✅ Answer: B. File descriptor
Explanation: File descriptor is an integer that a process uses to access an open file.
✅ 4. What is an inode in Unix?
A. A program to run commands
B. A data structure storing metadata about a file
C. A directory file
D. A user ID
✅ Answer: B. A data structure storing metadata about a file
✅ 5. What does the fork() system call do in Unix?
A. Creates a new process by duplicating the current process
B. Terminates a process
C. Allocates memory
D. Opens a file
✅ Answer: A. Creates a new process by duplicating the current process
✅ 6. How does Unix identify processes internally?
A. By file names
B. By process IDs (PIDs)
C. By user IDs
D. By device numbers
✅ Answer: B. By process IDs (PIDs)
✅ 7. Which data structure contains the details of a process in Unix?
A. Process Control Block (PCB)
B. File descriptor table
C. Directory entry
D. Superblock
✅ Answer: A. Process Control Block (PCB)
✅ 8. What is the function of the superblock in Unix file systems?
A. Store process information
B. Store metadata about the file system itself
C. Manage user permissions
D. Store device driver info
✅ Answer: B. Store metadata about the file system itself
✅ 9. What does the exec() system call do?
A. Replaces the current process image with a new program
B. Creates a new process
C. Terminates a process
D. Opens a file
✅ Answer: A. Replaces the current process image with a new program
✅ 10. Which of the following is NOT a Unix process state?
A. Running
B. Waiting
C. Ready
D. Sleeping indefinitely without a wait
✅ Answer: D. Sleeping indefinitely without a wait
✅ 11. What is the purpose of the 'init' process in Unix?
A. It is the first process started by the kernel during booting
B. Terminates all processes
C. Manages file permissions
D. Handles user logins
✅ Answer: A. It is the first process started by the kernel during booting
✅ 12. What mechanism does Unix use for inter-process communication?
A. Pipes, message queues, shared memory, and semaphores
B. Only shared memory
C. Only files
D. None
✅ Answer: A. Pipes, message queues, shared memory, and semaphores
✅ 13. Which part of the Unix kernel manages hardware devices?
A. Device drivers
B. Shell
C. File system
D. Process scheduler
✅ Answer: A. Device drivers
✅ 14. What does the 'wait()' system call do in Unix?
A. Creates a new process
B. Waits for a child process to terminate
C. Opens a file
D. Terminates a process
✅ Answer: B. Waits for a child process to terminate
✅ 15. Which of the following is true about Unix shell?
A. It is a command interpreter and scripting language interface
B. It is part of the kernel
C. It manages hardware resources
D. It schedules processes
✅ Answer: A. It is a command interpreter and scripting language interface
Unix Process – MCQs with Answers
✅ 1. What is a process in Unix?
A. A running instance of a program
B. A file stored on disk
C. A hardware device
D. A user account
✅ Answer: A. A running instance of a program
✅ 2. What system call is used to create a new process in Unix?
A. exec()
B. fork()
C. wait()
D. exit()
✅ Answer: B. fork()
✅ 3. After a fork() system call, what does the parent process receive?
A. PID of the child process
B. Return value 0
C. Error message
D. Nothing
✅ Answer: A. PID of the child process
✅ 4. What does the exec() system call do?
A. Terminates the current process
B. Replaces the current process image with a new program
C. Creates a new process
D. Suspends a process
✅ Answer: B. Replaces the current process image with a new program
✅ 5. Which system call is used by a parent process to wait for its child process
to finish?
A. exec()
B. fork()
C. wait()
D. signal()
✅ Answer: C. wait()
✅ 6. What is a zombie process in Unix?
A. A process that has completed execution but still has an entry in the process table
B. A process that is currently running
C. A process that is sleeping
D. A process waiting for I/O
✅ Answer: A. A process that has completed execution but still has an entry in the process
table
✅ 7. Which command displays the list of current running processes in Unix?
A. ls
B. ps
C. top
D. kill
✅ Answer: B. ps
✅ 8. What is the process ID (PID)?
A. A unique identifier assigned to each process
B. The name of the process
C. The priority level of the process
D. The owner of the process
✅ Answer: A. A unique identifier assigned to each process
✅ 9. What is a process state?
A. The current status of a process (e.g., running, waiting)
B. The process's user ID
C. The process's name
D. The size of the process
✅ Answer: A. The current status of a process (e.g., running, waiting)
✅ 10. Which of the following is NOT a typical Unix process state?
A. Running
B. Waiting
C. Ready
D. Completed
✅ Answer: D. Completed
Explanation: Completed processes become zombie or are removed from the process table.
✅ 11. What does the ‘kill’ command do in Unix?
A. Terminates a process by sending signals
B. Starts a new process
C. Lists all processes
D. Changes the priority of a process
✅ Answer: A. Terminates a process by sending signals
✅ 12. What is a daemon process in Unix?
A. A process that runs in the background without user interaction
B. A user interface program
C. A process that is waiting for I/O
D. A system error process
✅ Answer: A. A process that runs in the background without user interaction
✅ 13. What does the ‘nice’ command do?
A. Changes the priority of a process
B. Terminates a process
C. Lists processes
D. Starts a new process
✅ Answer: A. Changes the priority of a process
✅ 14. Which data structure stores information about a process in Unix?
A. File descriptor table
B. Process Control Block (PCB)
C. Directory entry
D. Superblock
✅ Answer: B. Process Control Block (PCB)
✅ 15. Which system call is used to terminate a process in Unix?
A. exec()
B. fork()
C. exit()
D. wait()
✅ Answer: C. exit()
Threads in Operating Systems – MCQs with Answers
✅ 1. What is a thread in an operating system?
A. A process that runs independently
B. The smallest unit of CPU execution within a process
C. A hardware component
D. A file in memory
✅ Answer: B. The smallest unit of CPU execution within a process
✅ 2. Which of the following is TRUE about threads?
A. Each thread has its own memory space
B. Threads within the same process share the same memory space
C. Threads cannot share data
D. Threads are managed by hardware only
✅ Answer: B. Threads within the same process share the same memory space
✅ 3. What is the main advantage of using threads?
A. Reduce CPU usage
B. Improve process communication and resource sharing
C. Increase disk usage
D. Eliminate the need for a scheduler
✅ Answer: B. Improve process communication and resource sharing
✅ 4. Which term describes multiple threads executing simultaneously on
multiple processors?
A. Multithreading
B. Multiprogramming
C. Multiprocessing
D. Multicore processing
✅ Answer: A. Multithreading
✅ 5. Which of the following is NOT a type of thread?
A. User-level threads
B. Kernel-level threads
C. Hardware threads
D. Virtual threads
✅ Answer: D. Virtual threads (common types are user-level and kernel-level threads)
✅ 6. What is the main difference between user-level threads and kernel-level
threads?
A. User-level threads are managed by the OS kernel
B. Kernel-level threads are managed by the OS kernel; user-level threads are managed by a
user library
C. Kernel-level threads share memory; user-level threads do not
D. User-level threads run on multiple processors, kernel threads do not
✅ Answer: B. Kernel-level threads are managed by the OS kernel; user-level threads are
managed by a user library
✅ 7. What is thread context switching?
A. Switching between different processes
B. Switching between different threads within the same process
C. Loading a program into memory
D. Scheduling a new process
✅ Answer: B. Switching between different threads within the same process
✅ 8. Which of the following is a common problem in multithreaded
programming?
A. Deadlock
B. Buffer overflow
C. Stack overflow
D. Segmentation fault
✅ Answer: A. Deadlock
✅ 9. What is the use of mutexes in threading?
A. To schedule threads
B. To provide mutual exclusion and avoid race conditions
C. To increase CPU speed
D. To terminate threads
✅ Answer: B. To provide mutual exclusion and avoid race conditions
✅ 10. What is a race condition?
A. When two or more threads try to access shared data concurrently causing inconsistency
B. When a thread finishes execution early
C. When a process is swapped out of memory
D. When a thread is idle
✅ Answer: A. When two or more threads try to access shared data concurrently causing
inconsistency
✅ 11. Which function is used to create a new thread in POSIX threads
(pthreads)?
A. pthread_create()
B. thread_start()
C. fork()
D. exec()
✅ Answer: A. pthread_create()
✅ 12. What does a thread’s stack contain?
A. Code of the program
B. Global variables
C. Local variables and function call information
D. Shared memory
✅ Answer: C. Local variables and function call information
✅ 13. Which of the following is TRUE about thread synchronization?
A. It is unnecessary in multithreading
B. It ensures correct sequencing of thread execution to prevent data races
C. It increases race conditions
D. It is handled automatically by hardware
✅ Answer: B. It ensures correct sequencing of thread execution to prevent data races
✅ 14. What is the benefit of multithreading in terms of CPU utilization?
A. It reduces CPU utilization
B. It helps keep the CPU busy by doing useful work while threads are waiting for I/O
C. It causes CPU idle time to increase
D. It disables parallel execution
✅ Answer: B. It helps keep the CPU busy by doing useful work while threads are waiting for
I/O
✅ 15. Which threading model maps many user-level threads to a single kernel
thread?
A. Many-to-many
B. Many-to-one
C. One-to-one
D. One-to-many
✅ Answer: B. Many-to-one
Signals in Operating Systems – MCQs with Answers
✅ 1. What is a signal in an operating system?
A. A hardware interrupt
B. A software notification sent to a process to notify an event
C. A file descriptor
D. A type of thread
✅ Answer: B. A software notification sent to a process to notify an event
✅ 2. Which signal is sent to a process to terminate it immediately?
A. SIGSTOP
B. SIGKILL
C. SIGTERM
D. SIGINT
✅ Answer: B. SIGKILL
✅ 3. What does the signal SIGINT represent?
A. Illegal instruction
B. Interrupt from keyboard (Ctrl+C)
C. Process terminated normally
D. Segmentation fault
✅ Answer: B. Interrupt from keyboard (Ctrl+C)
✅ 4. Which signal stops (pauses) a process?
A. SIGSTOP
B. SIGCONT
C. SIGTERM
D. SIGQUIT
✅ Answer: A. SIGSTOP
✅ 5. How can a process handle signals?
A. Ignore them
B. Catch them using a signal handler function
C. Let the default action happen
D. All of the above
✅ Answer: D. All of the above
✅ 6. What system call is used to send a signal to a process?
A. kill()
B. exec()
C. fork()
D. wait()
✅ Answer: A. kill()
✅ 7. What is the default action of the SIGTERM signal?
A. Terminate the process gracefully
B. Ignore the signal
C. Pause the process
D. Dump core and terminate
✅ Answer: A. Terminate the process gracefully
✅ 8. What is the purpose of the SIGCHLD signal?
A. Sent to parent when a child process terminates or stops
B. Sent to stop a process
C. Sent to indicate illegal memory access
D. Sent to resume a paused process
✅ Answer: A. Sent to parent when a child process terminates or stops
✅ 9. What does the signal SIGSEGV indicate?
A. Segmentation fault (invalid memory access)
B. Arithmetic error
C. Illegal instruction
D. Process stopped
✅ Answer: A. Segmentation fault (invalid memory access)
✅ 10. Which function is used to define a custom signal handler?
A. signal()
B. kill()
C. exec()
D. fork()
✅ Answer: A. signal()
✅ 11. What happens if a process ignores the SIGKILL signal?
A. The process terminates anyway
B. The process ignores it permanently
C. The process is paused
D. The process restarts
✅ Answer: A. The process terminates anyway
Explanation: SIGKILL cannot be caught or ignored.
✅ 12. Which signal resumes a stopped process?
A. SIGSTOP
B. SIGCONT
C. SIGINT
D. SIGTERM
✅ Answer: B. SIGCONT
✅ 13. What is the difference between SIGTERM and SIGKILL?
A. SIGTERM requests graceful termination; SIGKILL forces immediate termination
B. SIGKILL requests graceful termination; SIGTERM forces immediate termination
C. Both are the same
D. SIGTERM pauses process; SIGKILL continues it
✅ Answer: A. SIGTERM requests graceful termination; SIGKILL forces immediate
termination
✅ 14. What does the signal SIGPIPE indicate?
A. A process tried to write to a pipe without a reader
B. Process termination
C. Child process exit
D. Interrupt from keyboard
✅ Answer: A. A process tried to write to a pipe without a reader
✅ 15. Which signal is sent when a process divides by zero?
A. SIGFPE
B. SIGILL
C. SIGBUS
D. SIGSEGV
✅ Answer: A. SIGFPE
Inter Process Communication (IPC) – MCQs with Answers
✅ 1. What is Interprocess Communication (IPC)?
A. Communication between two computers
B. Mechanism that allows processes to communicate and synchronize with each other
C. Process scheduling method
D. Memory management technique
✅ Answer: B. Mechanism that allows processes to communicate and synchronize with each
other
✅ 2. Which of the following is NOT a common IPC method?
A. Pipes
B. Message Queues
C. Semaphores
D. Interrupts
✅ Answer: D. Interrupts
✅ 3. Which IPC method uses a FIFO buffer for communication?
A. Message Queues
B. Pipes
C. Shared Memory
D. Signals
✅ Answer: B. Pipes
✅ 4. What is a named pipe (FIFO)?
A. A pipe with a name in the file system that can be accessed by unrelated processes
B. A memory block shared between processes
C. A signal handler
D. A thread synchronization tool
✅ Answer: A. A pipe with a name in the file system that can be accessed by unrelated
processes
✅ 5. Which IPC method is the fastest?
A. Pipes
B. Shared Memory
C. Message Queues
D. Semaphores
✅ Answer: B. Shared Memory
Explanation: Shared memory allows processes to access common memory directly, making it
faster.
✅ 6. What is the main disadvantage of shared memory IPC?
A. High overhead
B. Requires synchronization mechanisms to avoid race conditions
C. Slow communication
D. No data sharing
✅ Answer: B. Requires synchronization mechanisms to avoid race conditions
✅ 7. Which IPC method provides synchronization along with communication?
A. Pipes
B. Semaphores
C. Shared Memory
D. Message Queues
✅ Answer: B. Semaphores
✅ 8. What is a semaphore in IPC?
A. A variable or abstract data type used to control access to a common resource
B. A communication channel
C. A file system object
D. A process scheduler
✅ Answer: A. A variable or abstract data type used to control access to a common resource
✅ 9. Which system call is used to create a pipe in Unix?
A. pipe()
B. mkfifo()
C. fork()
D. exec()
✅ Answer: A. pipe()
✅ 10. Message queues provide:
A. Unstructured communication
B. Structured message-based communication with priorities
C. Direct shared memory access
D. Only synchronization
✅ Answer: B. Structured message-based communication with priorities
✅ 11. Which IPC method requires processes to be related (e.g., parent and
child)?
A. Named pipes
B. Anonymous pipes
C. Shared Memory
D. Message Queues
✅ Answer: B. Anonymous pipes
✅ 12. How do processes synchronize when using shared memory?
A. By using semaphores or mutexes
B. By signals only
C. Automatically, no need for synchronization
D. By creating threads
✅ Answer: A. By using semaphores or mutexes
✅ 13. What does the system call shmget() do?
A. Creates a shared memory segment
B. Deletes a semaphore
C. Creates a message queue
D. Sends a signal
✅ Answer: A. Creates a shared memory segment
✅ 14. What is the purpose of the system call msgrcv()?
A. To receive a message from a message queue
B. To send a signal
C. To create a pipe
D. To allocate shared memory
✅ Answer: A. To receive a message from a message queue
✅ 15. Which IPC mechanism is suitable for communication between unrelated
processes on the same machine?
A. Anonymous pipes
B. Named pipes (FIFOs)
C. fork()
D. Threads
✅ Answer: B. Named pipes (FIFOs)