Unit 3 - Practice Quiz

CSE316

1 A situation where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place is called a(n):

A. Infinite Loop
B. Starvation
C. Race Condition
D. Deadlock

2 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. Context Switching speed

3 In the context of the Critical Section Problem, what does Bounded Waiting ensure?

A. No process waits forever to enter its critical section.
B. Only one process stays in the critical section at a time.
C. Processes run in a strict round-robin fashion.
D. The CPU is never idle.

4 A semaphore is an integer variable that, apart from initialization, is accessed only through two standard atomic operations, typically called:

A. Start and Stop
B. Wait and Signal
C. Read and Write
D. Test and Set

5 If a semaphore implementation uses busy waiting, the semaphore is often called a:

A. Monitor
B. Spinlock
C. Deadlock
D. Mutex

6 In the definition of the wait(S) operation for a semaphore , if the value of is non-positive, the process:

A. Increments and proceeds.
B. Sets to zero.
C. Waits (blocks or spins) until becomes positive.
D. Exits the system.

7 What is the primary advantage of a Counting Semaphore over a Binary Semaphore?

A. It is faster to implement.
B. It can control access to a given number of instances of a resource.
C. It prevents deadlocks automatically.
D. It requires no hardware support.

8 Which hardware instruction is defined atomically as: returns the original value of a boolean variable and sets the variable to true?

A. CompareAndSwap
B. TestAndSet
C. LoadAndStore
D. WaitAndSignal

9 In Peterson’s Solution for two processes, which two variables are shared between the processes?

A. Two semaphores
B. An integer turn and a boolean array flag
C. A mutex lock and a condition variable
D. A spinlock and a counter

10 The Producer-Consumer problem is also known as the:

A. Reader-Writer problem
B. Dining Philosophers problem
C. Bounded-Buffer problem
D. Sleeping Barber problem

11 In the Dining Philosophers Problem, if all philosophers pick up their left chopstick simultaneously, what condition occurs?

A. Starvation
B. Deadlock
C. Mutual Exclusion
D. Aging

12 A Monitor is a high-level synchronization construct that ensures:

A. Only one process can be active within the monitor at a time.
B. Processes can access monitor variables directly from outside.
C. Semaphores are never used inside the OS.
D. Deadlocks are impossible.

13 Which component is NOT shared among threads belonging to the same process?

A. Code section
B. Global variables
C. Open files
D. Stack pointer and Register set

14 In the Many-to-One multithreading model:

A. Many user-level threads map to many kernel threads.
B. Many user-level threads map to a single kernel thread.
C. Each user-level thread maps to a unique kernel thread.
D. The OS is aware of all user-level threads.

15 What is the primary disadvantage of the One-to-One multithreading model?

A. It does not support true concurrency on multiprocessors.
B. Creating a user thread requires creating a corresponding kernel thread, creating overhead.
C. If one thread blocks, all threads block.
D. It is impossible to implement on Linux.

16 A Precedence Graph is a directed acyclic graph (DAG) where nodes represent:

A. Resources
B. Individual statements or processes
C. Memory blocks
D. Critical sections

17 The Readers-Writers Problem prioritizes consistency by ensuring:

A. Multiple writers can write simultaneously.
B. Readers and writers can access data simultaneously.
C. Multiple readers can read simultaneously, but writers require exclusive access.
D. Writers always have priority over readers.

18 Condition variables in Monitors utilize which two operations?

A. Wait and Signal
B. P and V
C. Sleep and Wakeup
D. Lock and Unlock

19 In synchronization, what is a Binary Semaphore often equivalent to?

A. A Condition Variable
B. A Mutex Lock
C. A Spinlock
D. A Monitor

20 What is Scheduler Activation?

A. A hardware interrupt that starts the scheduler.
B. A scheme for communication between the user-thread library and the kernel.
C. The process of activating a sleeping process.
D. The initial boot sequence of the OS.

21 In the Two-Level Model of multithreading:

A. Threads are managed only by the kernel.
B. Threads are managed only by the user.
C. It combines Many-to-Many and One-to-One models.
D. Two threads run on one processor.

22 Which of the following is true regarding User-Level Threads?

A. The kernel is aware of them.
B. Context switching is generally faster than kernel-level threads.
C. They can utilize multiprocessor architectures easily without kernel support.
D. Blocking one user-level thread never blocks the entire process.

23 The Bakery Algorithm is a solution for:

A. The Reader-Writer problem.
B. Critical Section problem for processes.
C. Deadlock recovery.
D. Memory management.

24 In the Producer-Consumer problem using semaphores, what does the semaphore empty typically represent?

A. The number of full slots in the buffer.
B. The number of empty slots available in the buffer.
C. The status of the critical section.
D. The ID of the consumer process.

25 The signal(S) operation on a semaphore is typically defined as:

A.
B.
C.
D.

26 Co-operating processes are those that:

A. Run on different computers.
B. Do not share any data.
C. Can affect or be affected by other processes executing in the system.
D. Are strictly sequential.

27 Which mechanism informs a user-thread library that a kernel thread is about to block?

A. Downcall
B. Upcall
C. System Call
D. Interrupt

28 In a Monitor, if a thread calls x.wait(), what happens to the lock the thread holds?

A. The thread keeps the lock.
B. The thread releases the lock and suspends.
C. The monitor is destroyed.
D. The thread deadlocks immediately.

29 What is the Entry Section in process synchronization code?

A. The code executed after the critical section.
B. The code that requests permission to enter the critical section.
C. The part of the code where shared data is accessed.
D. The initialization of the process.

30 The CompareAndSwap (CAS) instruction takes three arguments: a memory location, an expected value, and a new value. It updates the memory location ONLY if:

A. The memory location currently holds the new value.
B. The memory location currently holds the expected value.
C. The memory location is empty.
D. The CPU is in kernel mode.

31 Which of the following is an example of a Heavyweight Process (HWP) compared to a thread?

A. A standard UNIX process with a single thread of control.
B. A Java thread.
C. A Pthread.
D. A Green thread.

32 In the Dining Philosophers solution using a Monitor, a philosopher is allowed to eat only if:

A. Both neighbors are eating.
B. One neighbor is eating.
C. Neither neighbor is eating.
D. They have a fork in the left hand.

33 If we use a semaphore to solve the Critical Section problem, the initial value of the semaphore should be:

A.
B. 1
C. N
D. -1

34 In the Signal and Continue monitor discipline:

A. The signaling thread waits until the signaled thread completes.
B. The signaled thread waits until the signaling thread completes.
C. The signaling thread continues executing, and the signaled thread becomes ready.
D. Both threads terminate.

35 A library that provides support for thread creation and management in user space without kernel support is known as:

A. Kernel-Level Threads (KLT)
B. Green Threads
C. Hyperthreading
D. Scheduler Activations

36 The fork() system call in a multithreaded environment (specifically POSIX):

A. Always duplicates all threads.
B. Is not allowed.
C. Usually duplicates only the calling thread.
D. Terminates the process.

37 What is Thread Local Storage (TLS)?

A. Data shared by all threads.
B. Data unique to each thread that persists across function calls.
C. The stack of the thread.
D. The CPU cache dedicated to a thread.

38 In the context of synchronization, what is Atomic Action?

A. An action that takes one clock cycle.
B. An action that effectively happens all at once or not at all (indivisible).
C. An action related to nuclear physics simulations.
D. An action that cannot be called by user programs.

39 Which of the following is a classic solution to the Readers-Writers problem that prevents writer starvation?

A. Reader preference.
B. Writer preference.
C. First-Come First-Served queueing semaphores.
D. Spinlocks.

40 The collection of instructions that follows the critical section is called the:

A. Entry Section
B. Remainder Section
C. Exit Section
D. Critical Section

41 Which multithreading model is generally used by Windows and Linux?

A. Many-to-One
B. One-to-One
C. Many-to-Many
D. None

42 What does the hardware instruction Swap(a, b) do?

A. Adds a and b.
B. Atomically exchanges the contents of variables a and b.
C. Compares a and b.
D. Copies a to b.

43 In a Precedence Graph, if there is an edge from node to , it implies:

A. must finish before starts.
B. must finish before starts.
C. and must run in parallel.
D. There is a deadlock between and .

44 Which of the following describes the Grand Central Dispatch (GCD) approach to threading?

A. A manual thread creation library.
B. An Apple technology that manages thread pools and schedules blocks of code.
C. A hardware synchronization primitive.
D. A Linux kernel scheduler.

45 What happens if a process utilizing user-level threads (Many-to-One model) makes a blocking system call?

A. Only the calling thread blocks.
B. The entire process blocks.
C. The kernel switches to another thread in the same process.
D. The system call is ignored.

46 The solution to the Producer-Consumer problem requires which two types of synchronization?

A. Mutual Exclusion and Synchronization (Signaling)
B. Deadlock prevention and Avoidance
C. Hardware and Software
D. User and Kernel

47 When a thread is cancelled asynchronously:

A. The target thread checks periodically if it should terminate.
B. The target thread is terminated immediately by another thread.
C. The target thread finishes its current function.
D. The target thread creates a child thread.

48 The Bounded-Buffer problem with buffers uses a semaphore mutex. What is its initial value?

A.
B. 1
C. N
D. N-1

49 In the context of the Critical Section, Progress implies that:

A. Processes in the remainder section decide who enters next.
B. Only processes not executing in their remainder sections can participate in deciding which will enter the critical section next.
C. The CPU must always be 100% utilized.
D. Context switches must happen every 10ms.

50 Which POSIX Pthread function is used to create a new thread?

A. pthread_create
B. pthread_start
C. pthread_fork
D. pthread_new