A.A situation where processes compete for the CPU scheduler
B.A condition where the operating system runs faster than the hardware
C.A condition where a process races to finish before the time quantum expires
D.A situation where several processes access and manipulate the same data concurrently and the outcome depends on the order of execution
Correct Answer: A situation where several processes access and manipulate the same data concurrently and the outcome depends on the order of execution
Explanation:
A race condition occurs when the final state of shared data depends on the specific order in which instructions are executed by concurrent processes.
Incorrect! Try again.
2Which of the following is NOT a requirement for a solution to the Critical Section Problem?
A.Mutual Exclusion
B.processor Speed
C.Bounded Waiting
D.Progress
Correct Answer: processor Speed
Explanation:
The solution to the critical section problem must satisfy Mutual Exclusion, Progress, and Bounded Waiting. It should not rely on the relative speed of the processors.
Incorrect! Try again.
3What does 'Mutual Exclusion' imply in the context of the Critical Section Problem?
A.Processes must share the same memory address space
B.If a process is executing in its critical section, then no other processes can be executing in their critical sections
C.All processes must execute their critical sections simultaneously
D.The operating system excludes processes from using the CPU
Correct Answer: If a process is executing in its critical section, then no other processes can be executing in their critical sections
Explanation:
Mutual exclusion ensures that only one process at a time is active within the critical section to prevent data inconsistency.
Incorrect! Try again.
4What is a Semaphore?
A.A protected integer variable that can only be accessed via two atomic operations
B.A hardware instruction
C.A queue of processes waiting for I/O
D.A specialized CPU register
Correct Answer: A protected integer variable that can only be accessed via two atomic operations
Explanation:
A semaphore is a synchronization tool (an integer variable) accessed only through two standard atomic operations: wait() and signal().
Incorrect! Try again.
5In a Semaphore, what does the 'wait' (or P) operation do?
A.Increments the semaphore value
B.Sets the semaphore value to zero
C.Decrements the semaphore value
D.Reads the semaphore value without changing it
Correct Answer: Decrements the semaphore value
Explanation:
The wait operation (P) decrements the semaphore value. If the value becomes negative, the process is blocked.
Incorrect! Try again.
6What is the main disadvantage of a Spinlock?
A.It is difficult to implement
B.It causes context switching
C.It requires busy waiting, wasting CPU cycles
D.It cannot handle multiple processes
Correct Answer: It requires busy waiting, wasting CPU cycles
Explanation:
Spinlocks cause the calling process to loop continuously (busy wait) while waiting for the lock to become available, which wastes CPU time.
Incorrect! Try again.
7A binary semaphore is also known as a:
A.Monitor
B.Mutex lock
C.Counting semaphore
D.Spinlock
Correct Answer: Mutex lock
Explanation:
A binary semaphore can range only between 0 and 1, functioning similarly to a Mutex (Mutual Exclusion) lock.
Incorrect! Try again.
8Which hardware instruction is commonly used to implement mutual exclusion?
A.LoadAndStore
B.JumpAndLink
C.PushAndPop
D.TestAndSet
Correct Answer: TestAndSet
Explanation:
TestAndSet is an atomic hardware instruction that tests a value and sets it, used to implement locks for mutual exclusion.
Incorrect! Try again.
9What is the 'Bounded Waiting' requirement?
A.A process must wait for a fixed amount of time
B.There exists a bound on the number of times other processes are allowed to enter their critical sections after a process has made a request to enter its critical section
C.The critical section size must be bounded
D.Processes must wait in a queue indefinitely
Correct Answer: There exists a bound on the number of times other processes are allowed to enter their critical sections after a process has made a request to enter its critical section
Explanation:
Bounded waiting ensures that a waiting process will eventually get into the critical section; it prevents starvation.
Incorrect! Try again.
10In the Producer-Consumer problem using a bounded buffer, when does the Producer wait?
A.When the mutex is unlocked
B.When the buffer is empty
C.When the buffer is full
D.When the Consumer is sleeping
Correct Answer: When the buffer is full
Explanation:
If the buffer is full, the producer cannot add new items and must wait until the consumer consumes an item.
Incorrect! Try again.
11Which of the following is a high-level synchronization construct that ensures mutual exclusion automatically?
A.Monitor
B.Peterson's Solution
C.Semaphore
D.Spinlock
Correct Answer: Monitor
Explanation:
A Monitor is a high-level abstraction where the compiler ensures that only one process can be active within the monitor at a time.
Incorrect! Try again.
12In the Dining Philosophers problem, deadlock occurs if:
A.Philosophers eat sequentially
B.The philosophers do not speak to each other
C.All philosophers pick up their left chopstick simultaneously
D.One philosopher picks up both chopsticks
Correct Answer: All philosophers pick up their left chopstick simultaneously
Explanation:
If every philosopher picks up the left chopstick at the same time, they will all wait indefinitely for the right chopstick, causing a circular wait (deadlock).
Incorrect! Try again.
13What is Peterson's Solution used for?
A.Solving the Critical Section problem for two processes
B.Scheduling threads
C.Handling hardware interrupts
D.Managing memory fragmentation
Correct Answer: Solving the Critical Section problem for two processes
Explanation:
Peterson's solution is a classic software-based solution to the critical section problem restricted to two processes.
Incorrect! Try again.
14In Peterson's solution, which variables are shared between processes?
A.start and finish
B.semaphore and mutex
C.lock and key
D.turn and flag
Correct Answer: turn and flag
Explanation:
Peterson's solution uses an integer variable 'turn' to indicate whose turn it is, and a boolean array 'flag' to indicate if a process is ready to enter the critical section.
Incorrect! Try again.
15What problem is the Readers-Writers problem primarily concerned with?
A.Ensuring exclusive access for writers while allowing multiple concurrent readers
B.Preventing readers from reading shared data
C.Allowing multiple writers to write simultaneously
D.Synchronizing two writers only
Correct Answer: Ensuring exclusive access for writers while allowing multiple concurrent readers
Explanation:
The problem allows multiple readers to read at the same time but requires that if a writer is writing, no other process (reader or writer) can access the shared data.
Incorrect! Try again.
16What happens to threads that call 'wait' on a Condition Variable in a Monitor?
A.They continue executing
B.They are terminated
C.They are suspended and placed in a waiting queue
D.They enter a busy-wait loop
Correct Answer: They are suspended and placed in a waiting queue
Explanation:
When a thread executes wait() on a condition variable, it releases the monitor lock and is suspended until another thread signals it.
Incorrect! Try again.
17Which of the following is NOT shared by threads of the same process?
A.Program Counter and Stack
B.Global variables
C.Code section
D.Open files
Correct Answer: Program Counter and Stack
Explanation:
Each thread has its own thread of execution, which requires a private Program Counter (PC), set of registers, and Stack. They share code, data, and files.
Incorrect! Try again.
18What is a Heavyweight Process compared to a Thread?
A.A process with no memory
B.A process with a single thread of control
C.A kernel-level thread
D.A thread with a large stack
Correct Answer: A process with a single thread of control
Explanation:
A traditional process (Heavyweight) has a single thread of control. Threads are often called Light Weight Processes (LWP).
Incorrect! Try again.
19Which multithreading model maps many user-level threads to a single kernel thread?
A.Many-to-One Model
B.Many-to-Many Model
C.One-to-One Model
D.Two-Level Model
Correct Answer: Many-to-One Model
Explanation:
The Many-to-One model maps multiple user threads to a single kernel thread. If one blocks, the entire process blocks.
Incorrect! Try again.
20What is a limitation of the Many-to-One multithreading model?
A.The entire process blocks if one thread makes a blocking system call
B.It is too complex to implement
C.It does not support user-level threads
D.It consumes too many kernel resources
Correct Answer: The entire process blocks if one thread makes a blocking system call
Explanation:
Since there is only one kernel thread, the OS sees the process as a single unit. If that unit blocks (e.g., for I/O), no other user thread in that process can run.
Incorrect! Try again.
21Which multithreading model provides more concurrency than Many-to-One but doesn't require a kernel thread for every user thread?
A.Many-to-Many Model
B.Single Thread Model
C.Independent Model
D.One-to-One Model
Correct Answer: Many-to-Many Model
Explanation:
The Many-to-Many model multiplexes many user-level threads to a smaller or equal number of kernel threads.
Incorrect! Try again.
22What is 'Scheduler Activation'?
A.A signal to kill a process
B.A mechanism for communication between the user-thread library and the kernel
C.The process of activating the CPU clock
D.A hardware interrupt that starts the scheduler
Correct Answer: A mechanism for communication between the user-thread library and the kernel
Explanation:
Scheduler activations provide a communication channel (often via upcalls) to maintain the correct number of kernel threads for the application's user threads.
Incorrect! Try again.
23Which standard defines the API for thread creation and synchronization (Pthreads)?
A.POSIX
B.ANSI
C.Java
D.Win32
Correct Answer: POSIX
Explanation:
Pthreads refers to POSIX Threads, a standard (IEEE 1003.1c) defining an API for thread creation and synchronization.
Incorrect! Try again.
24What is the function of pthread_join()?
A.Unlocks a mutex
B.Terminates a thread
C.Waits for a specific thread to terminate
D.Creates a new thread
Correct Answer: Waits for a specific thread to terminate
Explanation:
The pthread_join() function suspends execution of the calling thread until the target thread terminates.
Incorrect! Try again.
25A Precedence Graph is a directed acyclic graph used to:
A.Show the hierarchy of file systems
B.Map virtual memory to physical memory
C.Describe the execution dependencies among concurrent processes
D.Visualize the memory usage of a process
Correct Answer: Describe the execution dependencies among concurrent processes
Explanation:
Precedence graphs illustrate constraints on the order in which a collection of tasks or processes can execute.
Incorrect! Try again.
26What defines 'Co-operating Processes'?
A.Processes that can affect or be affected by other executing processes
B.Processes running on different computers
C.Processes that are completely independent
D.Processes that do not share data
Correct Answer: Processes that can affect or be affected by other executing processes
Explanation:
Co-operating processes share state (data or resources) and can influence one another's execution, requiring synchronization.
Incorrect! Try again.
27In the context of process hierarchy, what system call is typically used in Unix/Linux to create a new process?
A.new()
B.fork()
C.create()
D.spawn()
Correct Answer: fork()
Explanation:
The fork() system call creates a new process (child) which is a copy of the calling process (parent).
Incorrect! Try again.
28If a Semaphore S has a value of 10, and 5 P (wait) operations and 3 V (signal) operations are performed, what is the final value of S?
29What is the 'Bakery Algorithm' designed to solve?
A.Deadlock recovery
B.The Critical Section problem for N processes
C.The Producer-Consumer problem
D.Memory allocation
Correct Answer: The Critical Section problem for N processes
Explanation:
The Bakery Algorithm is a solution to the critical section problem for N processes, based on the idea of taking tickets in a bakery.
Incorrect! Try again.
30Which of the following is true regarding User-Level Threads (ULT)?
A.Context switching is faster than Kernel-Level Threads
B.They require hardware support
C.They cannot run on any OS
D.The kernel is aware of all ULTs
Correct Answer: Context switching is faster than Kernel-Level Threads
Explanation:
ULT management is done by a thread library in user space. Context switching is faster because it does not require kernel intervention (mode switching).
Incorrect! Try again.
31In the One-to-One multithreading model, what is the main drawback?
A.It is not standard
B.It does not support multiprocessors
C.Creating a user thread requires creating a corresponding kernel thread, which creates overhead
D.It blocks the whole process on I/O
Correct Answer: Creating a user thread requires creating a corresponding kernel thread, which creates overhead
Explanation:
While offering good concurrency, the overhead of creating a kernel thread for every user thread can burden the system.
Incorrect! Try again.
32What is an 'Upcall' in the context of Scheduler Activations?
A.A call from a user thread to the kernel
B.A notification from the kernel to the thread library
C.Uploading data to the cloud
D.increasing the priority of a thread
Correct Answer: A notification from the kernel to the thread library
Explanation:
The kernel uses an upcall to inform the application (thread library) about specific events, such as a processor becoming available or a thread blocking.
Incorrect! Try again.
33Which synchronization primitive is typically used to solve the Reader-Writer problem to prevent writer starvation?
A.Disable Interrupts
B.Semaphores with a priority queue
C.TestAndSet
D.Spinlocks
Correct Answer: Semaphores with a priority queue
Explanation:
Standard semaphores might lead to starvation; complex solutions or monitors often use priority mechanisms to ensure writers eventually get access.
Incorrect! Try again.
34What is 'Priority Inversion'?
A.A lower priority process holds a lock needed by a higher priority process
B.Inverting the bits of the semaphore
C.Assigning priority 0 to the most important process
D.The scheduler runs processes in reverse order
Correct Answer: A lower priority process holds a lock needed by a higher priority process
Explanation:
Priority inversion occurs when a high-priority task is indirectly preempted by a medium-priority task because a low-priority task holds a shared resource.
Incorrect! Try again.
35How does the 'Swap' hardware instruction assist in synchronization?
A.It moves a process to swap space
B.It swaps the content of two memory words atomically
C.It switches between user and kernel mode
D.It changes the process ID
Correct Answer: It swaps the content of two memory words atomically
Explanation:
The Swap instruction atomically exchanges the contents of two variables, which can be used to implement a lock (e.g., swapping a lock variable with 'true').
Incorrect! Try again.
36In a Monitor, if process P executes x.signal() and process Q was waiting on x, and Q immediately executes while P waits, this strategy is called:
A.Signal and Continue (Mesa semantics)
B.Busy Waiting
C.Signal and Wait (Hoare semantics)
D.Broadcast
Correct Answer: Signal and Wait (Hoare semantics)
Explanation:
In Hoare semantics (Signal and Wait), the signaler blocks to let the waiting thread run immediately.
Incorrect! Try again.
37Which component allows a thread to have its own copy of data?
A.Semaphore
B.Global Heap
C.TLS (Thread Local Storage)
D.Shared Memory
Correct Answer: TLS (Thread Local Storage)
Explanation:
Thread Local Storage (TLS) allows each thread to have its own instance of a variable, separate from other threads.
Incorrect! Try again.
38The problem where a producer tries to put an item into a full buffer is handled by:
A.Killing the consumer
B.Overwriting the oldest item
C.Putting the producer to sleep
D.Discarding the item
Correct Answer: Putting the producer to sleep
Explanation:
In standard synchronization solutions, the producer waits (sleeps) on a semaphore or condition variable until space is available.
Incorrect! Try again.
39Why is disabling interrupts not a viable solution for mutual exclusion in multiprocessor systems?
A.It requires too much power
B.It causes the OS to crash
C.It only disables interrupts on one processor, not all
D.It is too slow
Correct Answer: It only disables interrupts on one processor, not all
Explanation:
Disabling interrupts prevents the current CPU from switching tasks, but other CPUs can still access shared memory, failing to guarantee mutual exclusion.
Incorrect! Try again.
40What is 'Busy Waiting'?
A.The CPU executing a NOP instruction
B.A process waiting for I/O
C.A process repeatedly checking a condition until it becomes true
D.A process waiting in a queue
Correct Answer: A process repeatedly checking a condition until it becomes true
Explanation:
Busy waiting involves a continuous loop that consumes CPU cycles while checking if a lock or condition is available.
Incorrect! Try again.
41Which of the following is a valid state for a Java thread?
A.WAITING
B.BLOCKED
C.RUNNING
D.All of the above
Correct Answer: All of the above
Explanation:
Java threads can be in states such as NEW, RUNNABLE (Running), BLOCKED, WAITING, TIMED_WAITING, or TERMINATED.
Incorrect! Try again.
42In the context of threads, what is 'cancellation'?
A.Removing a semaphore
B.Stopping the CPU
C.Deleting the thread library
D.Terminating a thread before it has completed
Correct Answer: Terminating a thread before it has completed
Explanation:
Thread cancellation involves terminating a thread (the target thread) before it has finished its task (e.g., clicking 'Stop' in a web browser).
Incorrect! Try again.
43Deferred cancellation of a thread means:
A.The thread is cancelled after 1 minute
B.The thread is cancelled immediately
C.The thread cancels the parent process
D.The thread checks periodically if it should terminate
Correct Answer: The thread checks periodically if it should terminate
Explanation:
In deferred cancellation, the target thread periodically checks a flag to see if it should terminate, allowing it to clean up resources safely.
Incorrect! Try again.
44A solution to the Dining Philosophers problem using a monitor restricts a philosopher to pick up chopsticks only if:
A.The right neighbor is eating
B.Both neighbors are not eating
C.They have a ticket
D.The left neighbor is eating
Correct Answer: Both neighbors are not eating
Explanation:
To prevent deadlock and ensure mutual exclusion, a philosopher is allowed to change state to 'EATING' only if both left and right neighbors are not in 'EATING' state.
Incorrect! Try again.
45Which type of semaphore can take any non-negative integer value?
A.Mutex
B.Counting Semaphore
C.Binary Semaphore
D.Spinlock
Correct Answer: Counting Semaphore
Explanation:
Counting semaphores can range over an unrestricted domain and are used to control access to a given number of resources.
Incorrect! Try again.
46What defines a 'Thread Safe' function?
A.It can be called from multiple threads simultaneously without producing incorrect results
B.It runs very fast
C.It uses no memory
D.It creates a new thread
Correct Answer: It can be called from multiple threads simultaneously without producing incorrect results
Explanation:
Thread safety ensures that shared data structures are manipulated in a manner that guarantees safe execution by multiple threads at the same time.
Incorrect! Try again.
47In the 'Sleeping Barber' problem (a variation of producer-consumer), what happens if the customer arrives and the waiting room is full?
A.The customer leaves
B.The barber cuts two heads at once
C.The customer waits outside
D.The customer wakes the barber
Correct Answer: The customer leaves
Explanation:
In the standard Sleeping Barber problem, if there are no free chairs in the waiting room, the customer leaves the shop.
Incorrect! Try again.
48What is the benefit of the 'Grand Central Dispatch' (GCD) technology in macOS/iOS?
A.It creates infinite threads
B.It manages thread pools and scheduling automatically
C.It replaces the kernel
D.It increases clock speed
Correct Answer: It manages thread pools and scheduling automatically
Explanation:
GCD is an extension that allows application developers to identify sections of code to run in parallel, while the OS manages the threads.
Incorrect! Try again.
49Concurrency vs Parallelism: Which statement is true?
A.They are exactly the same
B.Parallelism requires multiple processors/cores, Concurrency does not
C.Parallelism is software only
D.Concurrency requires multiple processors
Correct Answer: Parallelism requires multiple processors/cores, Concurrency does not
Explanation:
Concurrency is about dealing with lots of things at once (logical), while Parallelism is about doing lots of things at once (physical hardware execution).
Incorrect! Try again.
50What is the primary purpose of a Condition Variable?
A.To allow threads to wait for a specific condition to become true
B.To store the process ID
C.To lock a file
D.To increment a counter
Correct Answer: To allow threads to wait for a specific condition to become true
Explanation:
Condition variables are synchronization primitives that enable threads to wait until a particular condition (state) occurs.