Operating System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

MCQ’S

What is the disadvantage of the Shortest Job First (SJF)


scheduling algorithm?
• a) Starvation
• b) Poor CPU utilization
• c) Complexity in implementation
• d) Overhead

Answer: a) Starvation
What is the process control block (PCB)?
• a) It stores all the information about a process.
• b) It controls the execution of processes.
• c) It allocates memory to the processes.
• d) It terminates the process.

Answer: a) It stores all the information about a process


Which scheduling algorithm is most appropriate for a time-sharing system?
• a) First-Come, First-Served
• b) Shortest Job First
• c) Round Robin
• d) Priority Scheduling

Answer: c) Round Robin


What is the process control block (PCB)?
• a) It stores all the information about a process.
• b) It controls the execution of processes.
• c) It allocates memory to the processes.
• d) It terminates the process.

Answer: a) It stores all the information about a process.


Which of the following is NOT a function of an operating system?
• a) Memory management
• b) Process management
• c) Data compression
• d) File system management

Answer: c) Data compression


Which of the following is a condition for deadlock in operating systems?
• a) Mutual exclusion
• b) Preemption
• c) In nite resources
• d) Round Robin scheduling

Answer: a) Mutual exclusion


fi
What is the main disadvantage of the Round Robin scheduling algorithm?
• a) It does not support preemption.
• b) It can lead to starvation.
• c) It has a high overhead due to frequent context switches.
• d) It favors long processes.

Answer: c) It has a high overhead due to frequent context switches.


Which memory management technique restricts each program to
be loaded into a single contiguous section of memory?
• a) Paging
• b) Segmentation
• c) Contiguous memory allocation
• d) Virtual memory

Answer: c) Contiguous memory allocation


Which of the following algorithms is used to avoid deadlock by
allocating resources in a way that guarantees the system remains in
a safe state?
• a) Round Robin
• b) Banker’s Algorithm
• c) First-Come, First-Served
• d) Shortest Job First

Answer: b) Banker’s Algorithm


Which of the following is true about the “Banker’s Algorithm” for deadlock
avoidance?
• a) It ensures that there will never be a deadlock in the system.
• b) It prevents circular wait by ordering resource allocation.
• c) It can lead to resource starvation in certain conditions.
• d) It can allocate resources even in an unsafe state.

Answer: c) It can lead to resource starvation in certain conditions.


In deadlock detection, what is the role of the “wait-for” graph?
•a) It represents which processes are waiting for which resources.
•b) It represents which processes are holding which resources.
•c) It helps detect circular wait conditions between processes.
•d) It provides a mechanism to break deadlocks by releasing resources.

Answer: c) It helps detect circular wait conditions between processes.


Explanation: The “wait-for” graph is used to represent processes and their resource
dependencies. If a cycle is detected in the graph, it indicates a circular wait and hence a
potential deadlock.
In a system that uses “demand paging,” which of the following can
result in a page fault?
• a) The page is already in physical memory.
• b) The page is marked as “dirty” in the page table.
• c) The page is referenced but not yet loaded into memory.
• d) The process accesses a page after the time quantum expires.

Answer: c) The page is referenced but not yet loaded into memory.
In a paged memory system, each page has a size of 4KB, and the
address size is 32 bits. What is the maximum number of pages a
process can have?
• a) 2^10
• b) 2^12
• c) 2^20
• d) 2^22
Answer: c) 2^20
Explanation: 32-bit address space means 2^32
addresses. Since the page size is 4KB (2^12), the
number of pages is 2^32 / 2^12 = 2^20.
In a multithreaded environment, when multiple threads access
shared data concurrently, which mechanism can be used to
ensure correct execution of operations?
• a) Context switching
• b) Interrupt handling
• c) Mutual exclusion using locks or semaphores
• d) Paging

Answer: c) Mutual exclusion using locks or semaphores


In a system with paging, the page table for a process is kept in memory.
To reduce the time required to access a page table entry, which of the
following techniques can be used?
• a) Cache memory
• b) Translation Lookaside Buffer (TLB)
• c) Disk scheduling
• d) Virtual memory

Answer: b) Translation Lookaside Buffer (TLB)


Consider a system using the Multilevel Feedback Queue scheduling
algorithm. Which of the following statements is true?
• a) All processes are treated equally, regardless of their behavior.
• b) Processes are moved between queues based on their behavior and execution
history.
• c) Each process is permanently assigned to a speci c queue based on priority.
• d) It always provides the shortest average waiting time.

Answer: b) Processes are moved between queues based on their behavior and execution history.
Explanation: The Multilevel Feedback Queue scheduling algorithm moves processes between
different priority queues based on how long they run and how often they are preempted, thus
dynamically adjusting the process priorities.

fi
In UNIX, a fork system call is used to create a new process. Which of the
following is NOT true about the process created by the fork call (child
process)?
• a) It is a duplicate of the parent process, with the same memory contents and
program counter.
• b) The child process has a different Process ID (PID) than the parent.
• c) File descriptors opened by the parent are also shared with the child.
• d) The child process inherits the memory and le locks of the parent.
Answer: d) The child process inherits the memory and le locks of the parent.
Explanation: The child process does not inherit the memory and le locks of the
parent process. While it inherits le descriptors, the locks and memory regions are
distinct.
fi
fi
fi
fi
Consider a set of processes with the following burst times:
• P1 = 10 ms, P2 = 5 ms, P3 = 8 ms.
• The scheduling algorithm used is Shortest Job First (SJF).
• What is the average waiting time for these processes?
Solution
Order of execution (Shortest Job First): P2 -> P3 -> P1.
• Waiting time:
P2 = 0 ms,
P3 = 5 ms (after P2),
P1 = 13 ms (after P2 and P3).
• Average waiting time = (0 + 5 + 13) / 3 = 6 ms.
Consider a set of 3 processes with the following burst times:
• P1 = 5 ms, P2 = 8 ms, P3 = 12 ms.
• If the system uses Round Robin (RR) scheduling with a time quantum of 4 ms,
calculate the total time required to complete all processes.
First Round: Each process gets 4 ms.
P1 (done), P2 (remaining 4 ms), P3 (remaining 8 ms)
Second Round: P2 (done), P3 (remaining 4 ms)
Third Round: P3 (done).
Total time = 5 ms (P1) + 8 ms (P2) + 12 ms (P3) = 25 ms.
A system uses Priority Scheduling with the following processes:
• P1 (priority 3), P2 (priority 1), P3 (priority 2), P4 (priority 4).
• Process burst times are: P1 = 4 ms, P2 = 9 ms, P3 = 3 ms, P4 = 5 ms.
• What is the order of execution of processes and the total completion
time?
Higher priority (lower number) processes are executed rst:
Order: P2 -> P3 -> P1 -> P4.
Total completion time: 9 ms (P2) + 3 ms (P3) + 4 ms (P1) + 5 ms
(P4) = 21 ms.

fi
Consider the following processes with their burst times and arrival times:

The scheduling algorithm used is First-Come, First-Served (FCFS).


• Calculate the average turnaround time.
Solution:
• Order of execution (FCFS): P1 -> P2 -> P3.
• Turnaround time = Completion time - Arrival time.
• Completion times:
P1 = 6 ms (starts at 0, ends at 6),
P2 = 8 ms (starts at 6, ends at 8),
P3 = 16 ms (starts at 8, ends at 16).
• Turnaround times:
P1 = 6 - 0 = 6 ms,
P2 = 8 - 2 = 6 ms,
P3 = 16 - 4 = 12 ms.
• Average turnaround time = (6 + 6 + 12) / 3 = 8 ms.
Consider a system with segmented memory management and demand paging. If a
segment contains 64 pages, each of size 4KB, and the segment table entry size is 4
bytes, what is the total size of the segment table for this segment?

• a) 64 bytes

• b) 256 bytes

• c) 512 bytes

• d) 1024 bytes

Answer: B) 256 bytes

Explanation: The segment has 64 pages, and each segment table entry is 4 bytes.
Therefore, the total size of the segment table is 64 *4 = 256 bytes for page entries,
and IF we also need to store segment information, the total size is 512 bytes.
In a system with non-contiguous memory allocation using paging, the TLB miss rate is
8%, and the main memory access time is 200 ns. If the time to handle a TLB miss is
600 ns, what is the e ective memory access time?

• a) 216 ns

• b) 248 ns

• c) 256 ns

• d) 296 ns

Answer: d) 296 ns
ff
Consider a system with hardware support for segmentation and paging. A
process has 5 segments, each containing 16 pages, with each page being 1KB.
What is the minimum number of bits required to represent a logical address in
this system?

• a) 10 bits

• b) 15 bits

• c) 19 bits

• d) 24 bits Answer: c) 19 bits


Thus, the minimum number of bits required to represent the logical address is 17 bits.
However, this number of bits represents the absolute minimum. Depending on speci c
hardware architecture, logical addressing might use a few extra bits for alignment,
padding, or control purposes. Therefore, the minimum practical number of bits
required could be rounded up to the nearest standard width, which in this case
would be 19 bits. Hence, the correct answer is:
Answer: c) 19 bits.

fi
In process creation, which of the following is responsible for copying the address space
and process environment of the parent to the child?
• A) fork()
• B) exec()
• C) clone()
• D) thread_create()
Answer: A) fork()
Which of the following is a major problem with Race Conditions?
• A) The execution outcome depends on the order of thread/process execution.
• B) It prevents multithreading.
• C) It uses excessive CPU time.
• D) It blocks user input.

Answer: A) The execution outcome depends on the order of thread/process execution.


In a multithreaded process, which of the following resources is NOT shared among
threads?
• A) Program counter
• B) Global variables
• C) Code section
• D) Heap memory

Answer: A) Program counter


Which of the following is TRUE for Paging?
• A) All processes must be in contiguous memory blocks.
• B) Paging eliminates the problem of external fragmentation.
• C) Paging can only be used in preemptive scheduling systems.
• D) Paging does not require hardware support.

Answer: B) Paging eliminates the problem of external fragmentation.


Which of the following is an advantage of Segmentation over paging?
• A) It allows processes to be broken down into logical units.
• B) It avoids external fragmentation.
• C) It simpli es page table management.
• D) It reduces context-switching time.

Answer: A) It allows processes to be broken down into logical units.


fi
Thrashing occurs when:
• A) There is excessive swapping between memory and disk.
• B) A page replacement algorithm fails to nd a free page.
• C) Virtual memory is disabled.
• D) The system runs out of physical memory.

Answer: A) There is excessive swapping between memory and disk.

fi
The concept of Monitors in concurrency control:
• A) Requires that only one process is active within a monitor at any time.
• B) Provides a hardware-based solution to synchronization.
• C) Is used only in non-preemptive systems.
• D) Cannot be implemented using semaphores.
Answer: A) Requires that only one process is active within a monitor at any time.
Which of the following is TRUE for Mutexes?
• A) A mutex allows multiple threads to access the same critical section at once.
• B) A mutex must be unlocked by the thread that locked it.
• C) Mutexes can lead to race conditions if used incorrectly.
• D) A mutex can be locked by one thread and unlocked by another.
Answer: B) A mutex must be unlocked by the thread that locked it.
In a system with priority scheduling, which of the following is a common problem, and how i
resolved?
• A) Starvation, solved by aging
• B) Deadlock, solved by preemption
• C) High CPU utilization, solved by round robin
• D) Low throughput, solved by First-Come-First-Served

Answer: A) Starvation, solved by aging


In demand paging, the page fault rate is in uenced by:
• A) The size of the pages used by the operating system.
• B) The number of frames allocated to the process.
• C) The amount of time taken by the CPU to process each instruction.
• D) The number of processes in the ready queue.

Answer: B) The number of frames allocated to the process

fl
Which of the following page replacement algorithms is theoretically optimal but
impractical to implement, and why?
• A) Least Recently Used (LRU), because it requires additional hardware for tracking
usage.
• B) FIFO, because it does not consider the frequency of page accesses.
• C) Optimal Page Replacement, because it requires future knowledge of the memory
reference string.
• D) Clock Algorithm, because it has higher overhead than LRU.
Answer: C) Optimal Page Replacement, because it requires future knowledge of the
memory reference string.
In the context of deadlock recovery, why is process termination typically avoided as a
rst option?
• A) It may cause cascading failures in other processes due to dependency chains.
• B) It does not guarantee that resources will be freed for other processes.
• C) It requires signi cant computational resources to restart terminated processes.
• D) It leads to permanent resource leaks in the system.
Answer: A) It may cause cascading failures in other processes due to dependency
chains.
fi
fi
Which of the following is TRUE regarding Belady’s anomaly in page
replacement algorithms?
• A) It is observed in the Least Recently Used (LRU) algorithm.
• B) It describes the situation where more frames result in fewer page faults.
• C) It occurs when adding more frames increases the number of page faults.
• D) It is caused by improper process synchronization.

Answer: C) It occurs when adding more frames increases the number of page faults.
Given a system using segmented paging with a segment size of 64KB and a page size of
4KB, how many bits are needed for the page offset, and what does this imply about the
page table structure?
• A) 10 bits for page offset, implying each page table entry points to a segment.
• B) 12 bits for page offset, implying the system supports large page sizes.
• C) 12 bits for page offset, implying that each segment can contain up to 16 pages.
• D) 10 bits for page offset, implying that the page tables themselves are segmented.

Answer: D) 10 bits for page offset, implying that the page tables themselves are segmented.
Which of the following is true about a CPU-bound process?
•A) Spends more time on I/O operations
• B) Spends more time on computation
• C) Requires less memory than I/O-bound processes
• D) Utilizes the CPU and I/O equally

Answer: B (Spends more time on computation)


Which of the following page replacement algorithms suffers from Belady's
anomaly?
• A) Least Recently Used (LRU)
• B) Optimal Page Replacement
• C) First-In-First-Out (FIFO)
• D) Clock Algorithm

Answer: C (First-In-First-Out)
Explanation:
Belady's anomaly occurs in FIFO when increasing the number of page frames
results in more page faults. LRU and Optimal do not suffer from this anomaly.
In virtual memory, when the system spends most of its time swapping pages rather than executin
processes, this condition is known as:
• A) Fragmentation
• B) Paging
• C) Thrashing
• D) Segmentation

Answer: C (Thrashing)
What is a zombie process in Unix-like systems?
• A) A process that has completed execution but still has an entry in the process table
• B) A process that is running in the background inde nitely
• C) A process that consumes all CPU resources without completing
• D) A process that has been suspended by the user

Answer: A (A process that has completed execution but still has an entry in the
process table)
Explanation:
A zombie process occurs when a process has nished execution, but its parent process has
not yet read its exit status, leaving an entry in the process table.
fi
fi
In UNIX, the le descriptor for standard input (stdin) is:
• A) 0
• B) 1
• C) 2
• D) 3
Answer: A (0)

Explanation:
In UNIX, le descriptors are integers that refer to open les. 0 is for standard input, 1 for standard
output, and 2 for standard error.
fi
fi
fi

You might also like