Unit 3: Process Synchronization and Threads - Practice Quiz

CSE316 — Operating Systems 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What is a 'Race Condition' in Operating Systems?

A. A condition where a process races to finish before the time quantum expires
B. A condition where the operating system runs faster than the hardware
C. A situation where processes compete for the CPU scheduler
D. A situation where several processes access and manipulate the same data concurrently and the outcome depends on the order of execution

2 Which of the following is NOT a requirement for a solution to the Critical Section Problem?

A. processor Speed
B. Mutual Exclusion
C. Progress
D. Bounded Waiting

3 What does 'Mutual Exclusion' imply in the context of the Critical Section Problem?

A. Processes must share the same memory address space
B. All processes must execute their critical sections simultaneously
C. If a process is executing in its critical section, then no other processes can be executing in their critical sections
D. The operating system excludes processes from using the CPU

4 What is a Semaphore?

A. A specialized CPU register
B. A queue of processes waiting for I/O
C. A hardware instruction
D. A protected integer variable that can only be accessed via two atomic operations

5 In a Semaphore, what does the 'wait' (or P) operation do?

A. Decrements the semaphore value
B. Sets the semaphore value to zero
C. Increments the semaphore value
D. Reads the semaphore value without changing it

6 What is the main disadvantage of a Spinlock?

A. It is difficult to implement
B. It cannot handle multiple processes
C. It requires busy waiting, wasting CPU cycles
D. It causes context switching

7 A binary semaphore is also known as a:

A. Counting semaphore
B. Spinlock
C. Mutex lock
D. Monitor

8 Which hardware instruction is commonly used to implement mutual exclusion?

A. JumpAndLink
B. LoadAndStore
C. PushAndPop
D. TestAndSet

9 What is the 'Bounded Waiting' requirement?

A. 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
B. The critical section size must be bounded
C. A process must wait for a fixed amount of time
D. Processes must wait in a queue indefinitely

10 In the Producer-Consumer problem using a bounded buffer, when does the Producer wait?

A. When the buffer is empty
B. When the buffer is full
C. When the mutex is unlocked
D. When the Consumer is sleeping

11 Which of the following is a high-level synchronization construct that ensures mutual exclusion automatically?

A. Spinlock
B. Peterson's Solution
C. Semaphore
D. Monitor

12 In the Dining Philosophers problem, deadlock occurs if:

A. All philosophers pick up their left chopstick simultaneously
B. The philosophers do not speak to each other
C. Philosophers eat sequentially
D. One philosopher picks up both chopsticks

13 What is Peterson's Solution used for?

A. Scheduling threads
B. Handling hardware interrupts
C. Solving the Critical Section problem for two processes
D. Managing memory fragmentation

14 In Peterson's solution, which variables are shared between processes?

A. semaphore and mutex
B. turn and flag
C. lock and key
D. start and finish

15 What problem is the Readers-Writers problem primarily concerned with?

A. Allowing multiple writers to write simultaneously
B. Synchronizing two writers only
C. Ensuring exclusive access for writers while allowing multiple concurrent readers
D. Preventing readers from reading shared data

16 What happens to threads that call 'wait' on a Condition Variable in a Monitor?

A. They enter a busy-wait loop
B. They continue executing
C. They are suspended and placed in a waiting queue
D. They are terminated

17 Which of the following is NOT shared by threads of the same process?

A. Code section
B. Global variables
C. Program Counter and Stack
D. Open files

18 What is a Heavyweight Process compared to a Thread?

A. A process with no memory
B. A kernel-level thread
C. A process with a single thread of control
D. A thread with a large stack

19 Which multithreading model maps many user-level threads to a single kernel thread?

A. Many-to-One Model
B. Two-Level Model
C. Many-to-Many Model
D. One-to-One Model

20 What is a limitation of the Many-to-One multithreading model?

A. It does not support user-level threads
B. It consumes too many kernel resources
C. The entire process blocks if one thread makes a blocking system call
D. It is too complex to implement

21 Which multithreading model provides more concurrency than Many-to-One but doesn't require a kernel thread for every user thread?

A. Independent Model
B. One-to-One Model
C. Single Thread Model
D. Many-to-Many Model

22 What is 'Scheduler Activation'?

A. A mechanism for communication between the user-thread library and the kernel
B. The process of activating the CPU clock
C. A hardware interrupt that starts the scheduler
D. A signal to kill a process

23 Which standard defines the API for thread creation and synchronization (Pthreads)?

A. Java
B. POSIX
C. ANSI
D. Win32

24 What is the function of pthread_join()?

A. Terminates a thread
B. Unlocks a mutex
C. Creates a new thread
D. Waits for a specific thread to terminate

25 A Precedence Graph is a directed acyclic graph used to:

A. Describe the execution dependencies among concurrent processes
B. Show the hierarchy of file systems
C. Visualize the memory usage of a process
D. Map virtual memory to physical memory

26 What defines 'Co-operating Processes'?

A. Processes running on different computers
B. Processes that do not share data
C. Processes that can affect or be affected by other executing processes
D. Processes that are completely independent

27 In the context of process hierarchy, what system call is typically used in Unix/Linux to create a new process?

A. fork()
B. create()
C. new()
D. spawn()

28 If 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?

A. 12
B. 2
C. 10
D. 8

29 What is the 'Bakery Algorithm' designed to solve?

A. Memory allocation
B. Deadlock recovery
C. The Producer-Consumer problem
D. The Critical Section problem for N processes

30 Which of the following is true regarding User-Level Threads (ULT)?

A. The kernel is aware of all ULTs
B. They require hardware support
C. Context switching is faster than Kernel-Level Threads
D. They cannot run on any OS

31 In the One-to-One multithreading model, what is the main drawback?

A. It does not support multiprocessors
B. Creating a user thread requires creating a corresponding kernel thread, which creates overhead
C. It blocks the whole process on I/O
D. It is not standard

32 What is an 'Upcall' in the context of Scheduler Activations?

A. Uploading data to the cloud
B. A notification from the kernel to the thread library
C. A call from a user thread to the kernel
D. increasing the priority of a thread

33 Which synchronization primitive is typically used to solve the Reader-Writer problem to prevent writer starvation?

A. Semaphores with a priority queue
B. Spinlocks
C. TestAndSet
D. Disable Interrupts

34 What is 'Priority Inversion'?

A. Assigning priority 0 to the most important process
B. Inverting the bits of the semaphore
C. A lower priority process holds a lock needed by a higher priority process
D. The scheduler runs processes in reverse order

35 How does the 'Swap' hardware instruction assist in synchronization?

A. It swaps the content of two memory words atomically
B. It moves a process to swap space
C. It switches between user and kernel mode
D. It changes the process ID

36 In 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. Signal and Wait (Hoare semantics)
C. Broadcast
D. Busy Waiting

37 Which component allows a thread to have its own copy of data?

A. Semaphore
B. Global Heap
C. Shared Memory
D. TLS (Thread Local Storage)

38 The problem where a producer tries to put an item into a full buffer is handled by:

A. Discarding the item
B. Putting the producer to sleep
C. Overwriting the oldest item
D. Killing the consumer

39 Why is disabling interrupts not a viable solution for mutual exclusion in multiprocessor systems?

A. It causes the OS to crash
B. It only disables interrupts on one processor, not all
C. It requires too much power
D. It is too slow

40 What is 'Busy Waiting'?

A. A process waiting for I/O
B. A process repeatedly checking a condition until it becomes true
C. A process waiting in a queue
D. The CPU executing a NOP instruction

41 Which of the following is a valid state for a Java thread?

A. RUNNING
B. BLOCKED
C. WAITING
D. All of the above

42 In the context of threads, what is 'cancellation'?

A. Deleting the thread library
B. Terminating a thread before it has completed
C. Removing a semaphore
D. Stopping the CPU

43 Deferred cancellation of a thread means:

A. The thread cancels the parent process
B. The thread checks periodically if it should terminate
C. The thread is cancelled after 1 minute
D. The thread is cancelled immediately

44 A solution to the Dining Philosophers problem using a monitor restricts a philosopher to pick up chopsticks only if:

A. Both neighbors are not eating
B. They have a ticket
C. The left neighbor is eating
D. The right neighbor is eating

45 Which type of semaphore can take any non-negative integer value?

A. Binary Semaphore
B. Mutex
C. Counting Semaphore
D. Spinlock

46 What defines a 'Thread Safe' function?

A. It can be called from multiple threads simultaneously without producing incorrect results
B. It creates a new thread
C. It uses no memory
D. It runs very fast

47 In 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 customer waits outside
C. The customer wakes the barber
D. The barber cuts two heads at once

48 What is the benefit of the 'Grand Central Dispatch' (GCD) technology in macOS/iOS?

A. It manages thread pools and scheduling automatically
B. It increases clock speed
C. It replaces the kernel
D. It creates infinite threads

49 Concurrency vs Parallelism: Which statement is true?

A. Parallelism requires multiple processors/cores, Concurrency does not
B. Parallelism is software only
C. They are exactly the same
D. Concurrency requires multiple processors

50 What is the primary purpose of a Condition Variable?

A. To increment a counter
B. To allow threads to wait for a specific condition to become true
C. To lock a file
D. To store the process ID