wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSF20303_Chap 4 : Multithreaded Programming

Total questions: 100

Worksheet time: 55mins

Name
Class
Date
1.

Which scenario best demonstrates applying thread responsiveness to improve user experience?

a)

Adding more RAM to increase process speed

b)

Splitting a UI program so UI updates continue while data loads

c)

Rebooting the OS to reset blocked processes

d)

Combining all program functions into one loop

2.

A developer wants to redesign an application so that tasks like spell checking and fetching data can occur simultaneously. Which OS concept should be applied?

a)

Virtual memory

b)

Multithreading

c)

Device drivers

d)

Paging

3.

Given a system with heavy data-splitting needs, which type of parallelism is most applicable?

a)

Task parallelism

b)

Data parallelism

c)

Virtual parallelism

d)

Logical parallelism

4.

A programmer needs to distribute unique tasks across multiple cores. Which type of parallelism should be applied?

a)

Data parallelism

b)

Serial execution

c)

Task parallelism

d)

Cooperative memory

5.

A process requires faster context switching with minimal overhead. Which execution model should be applied?

a)

Process creation model

b)

Heavyweight scheduling

c)

Multithreading

d)

Distributed OS

6.

A CPU with a single core needs to run multiple threads that appear simultaneous. Which OS concept enables this?

a)

True parallelism

b)

Hardware pipelining

c)

Concurrency

d)

Multi-booting

7.

Applying Amdahl’s Law, increasing the number of cores gives diminishing returns because:

a)

Parallel tasks consume more RAM

b)

Serial portions limit total speedup

c)

Cores communicate too slowly

d)

OS prevents scaling beyond four cores

8.

A programmer needs every new user-level thread to map to a kernel thread. Which model should be chosen?

a)

Many-to-One

b)

One-to-One

c)

Many-to-Many

d)

Hybrid caching

9.

When designing an application requiring thousands of threads but limited kernel overhead, which model is most applicable?

a)

One-to-one

b)

Many-to-one

c)

Many-to-many

d)

Single-threaded

10.

A thread library that must function when programmer has no control over thread creation should use:

a)

Local variables

b)

Static memory

c)

Thread-local storage

d)

Shared memory pages

11.

To allow different strategies for running tasks without recreating threads, which technique should be applied?

a)

Fork-join execution

b)

Thread pools

c)

Synchronous signals

d)

TLB caching

12.

A developer wants an algorithm where tasks recursively fork and later combine results. Which method should be used?

a)

Grand Central Dispatch

b)

Fork-Join model

c)

Pthreads mutex

d)

Hybrid paging

13.

To implement parallel loops in C using compiler directives, the developer should use:

a)

GCD closures

b)

OpenMP

c)

Java Runnable

d)

TBB only

14.

When using OpenMP, adding #pragma omp parallel results in:

a)

A. A single serial thread

b)

B. Threads equal to number of CPU cores

c)

C. One kernel thread per process

d)

D. Threads only on Windows

15.

A task queue where multiple items run concurrently in FIFO order is which GCD queue type?

a)

Serial

b)

Priority

c)

Concurrent

d)

Random

16.

A developer uses the Java Executor Framework instead of manually creating threads. What is applied?

a)

Implicit threading

b)

Direct thread scheduling

c)

Kernel thread binding

d)

Memory swapping

17.

To achieve parallel C++ loops using Intel TBB, which construct should be applied?

a)

parallel_for

b)

omp_task

c)

dispatch_sync

d)

exec_thread

18.

To cancel a thread only at safe points, which cancellation type applies?

a)

Forced cancellation

b)

Asynchronous cancellation

c)

Deferred cancellation

d)

Timed cancellation

19.

A Java developer checks Thread.currentThread().isInterrupted(). What is applied?

4 lines
20.

A UNIX program needs a user-defined function to process events like segmentation faults. Which mechanism applies?

a)

Paging handler

b)

Interrupt vector

c)

Signal handler

d)

Register swapping

21.

To send all signals to one dedicated thread, which strategy applies?

a)

Deliver to all threads

b)

Deliver to random thread

c)

Deliver to specific assigned thread

d)

Ignore signals

22.

Which mechanism maintains correct number of kernel threads in M:M threading?

a)

Thread cloning

b)

Scheduling activations

c)

JNI callbacks

d)

Deadlock detection

23.

To bind a user thread to a kernel thread in M:M mapping, which model applies?

a)

One-to-One

b)

Two-Level model

c)

Many-to-One

d)

Hybrid paging model

24.

To implement POSIX-compliant threads in Linux, which API is applied?

a)

LWP API

b)

Pthreads

c)

GCD API

d)

WinThread API

25.

Using pthread_join() applies which concept?

a)

Thread synchronization

b)

Thread cancellation

c)

Thread pooling

d)

Interrupt dispatch

26.

A Windows program using CreateThread() applies which model?

a)

Many-to-one

b)

Single-threaded

c)

One-to-one

d)

Signal-based threading

27.

A system using clone() to create tasks that share address space refers to which OS?

a)

Windows

b)

macOS

c)

Linux

d)

BSD

28.

In GCD, tasks are assigned to available threads from:

a)

User thread pool

b)

Kernel-controlled thread pool

c)

Manual thread list

d)

Local thread counter

29.

Splitting data across cores for identical operations is:

a)

Task pipelining

b)

Data parallelism

c)

Linked scheduling

d)

Mutual exclusion

30.

A queue removing tasks in FIFO concurrently represents:

a)

Thread binding

b)

Scheduler activation

c)

GCD concurrent queue

d)

Exec handler

31.

The register set, stacks, and private storage of a thread are called:

a)

Thread-local swap

b)

Thread context

c)

Page frame

d)

Hardware interrupt

32.

TLS is used when the programmer must prevent:

a)

Stack overflow

b)

Data overwrite among threads

c)

Page faults

33.

If fork() should not duplicate all threads, which semantic applies?

a)

Full duplication

b)

Single-threaded duplication

c)

Random duplication

d)

Deferred duplication

34.

Branching and joining tasks is characteristic of:

a)

OpenMP

b)

Fork-join parallelism

c)

Thread cancellation

d)

Windows scheduler

35.

dispatch_async() in Swift triggers:

a)

Synchronous execution

b)

Immediate blocking

c)

Asynchronous task dispatch

d)

Thread cancellation

36.

Faster creation and switching of threads than processes is which benefit?

a)

Scalability

b)

Responsiveness

c)

Economy

d)

Resource duplication

37.

Debugging multithreaded programs on multicore CPUs is difficult due to:

a)

Reduced stack usage

b)

Data dependencies

c)

Smaller register files

d)

Lower clock speed

38.

A server creating a new thread for each request represents:

a)

Single-thread loop

b)

Multithreaded server architecture

c)

Kernel swapping

d)

Deferred cancellation

39.

Multiple tasks running simultaneously on multicore hardware represent:

(a)  

40.

Which of the following is a method for avoiding deadlocks?

a)

Preemption

b)

Parallelism

c)

Deadlock avoidance

d)

Kernel thread reassignment

41.

pthread_testcancel() introduces:

a)

Immediate cancellation

b)

A cancellation point

c)

Thread ID reset

d)

Kernel thread reassignment

42.

To return a value in Java threading, the developer uses:

a)

Runnable

b)

RecursiveAction

c)

Callable with Executor

d)

ThreadLocal

43.

In Windows, user-mode stack and TLS are stored in:

a)

ETHREAD

b)

KTHREAD

c)

TEB

d)

PCB

44.

To create a thread and wait for it to finish in Windows:

a)

CreateThread() → WaitForSingleObject()

b)

clone() → exec()

c)

pthread_create() → pthread_join()

d)

dispatch_sync() → dispatch_wait()

45.

To parallelize loops in C++ using templates, use:

a)

Pthreads

b)

TBB

c)

GCD

d)

OpenMP only

46.

Thread pools support applications where tasks:

a)

Require manual termination

b)

Are created frequently

c)

Must run serially

d)

Must block main thread

47.

Delivering a signal to all threads is useful when:

a)

The signal applies globally

b)

Only one thread needs it

c)

Signals must be suppressed

d)

OS prohibits per-thread signals

48.

If cancellation is pending but disabled, it occurs when:

a)

Thread exits abruptly

b)

Thread enables cancellation later

c)

Kernel forces termination

d)

Scheduler swaps stacks

49.

OS determining optimal kernel threads relates to:

a)

1:1

b)

M:1

c)

M:M

d)

No threading

50.

A dedicated thread handling all cleanup = assigning:

a)

Signal handler thread

b)

Clone() child

c)

Runnable wrapper

d)

Memory dispatcher

51.

A Linux thread created via clone() sharing address space is:

a)

Independent process

b)

User-level thread only

c)

Kernel-level task

d)

Forked VM copy

52.

A software team wants to prevent UI freezing during long operations. Which concept helps?

a)

Paging

b)

Multithreading

c)

CPU scheduling

d)

Memory compaction

53.

Splitting array subsets for identical operations shows:

a)

Serial execution

b)

Data parallelism

c)

Interrupt-driven flow

54.

When serial code limits speedup regardless of cores, which law applies?

a)

Little’s Law

b)

Amdahl’s Law

c)

Murphy’s Law

d)

Newton’s Law

55.

A developer needs each user thread mapped to one kernel thread:

a)

M:1

b)

1:1

c)

M:M

d)

Two-level only

56.

In M:1, if a thread blocks during I/O:

a)

Other threads continue

b)

All user threads block

c)

Kernel creates new threads

d)

Memory grows

57.

To maximize concurrency but limit kernel threads:

a)

M:1

b)

1:1

c)

M:M

d)

Serial execution

58.

Which system most commonly supports Pthreads?

a)

Windows

b)

UNIX-like systems

c)

DOS

d)

ChromeOS only

59.

pthread_exit() is used to:

a)

Destroy mutex

b)

Swap context

c)

Terminate a thread safely

d)

Replace the process

60.

WaitForSingleObject() is used to:

4 lines
61.

Java threads most commonly use:

a)

Runnable

b)

Comparator

c)

Clonable

d)

Iterator

62.

A thread that returns a value in Java uses:

a)

Runnable

b)

Callable

c)

ThreadGroup

d)

Volatile

63.

To avoid recreating threads repeatedly:

a)

Serial queue

b)

Thread pools

c)

Direct signals

d)

Manual scheduling

64.

Which directive runs code in parallel in C/C++?

a)

#pragma omp thread

b)

#pragma omp start

c)

#pragma omp parallel

d)

#pragma omp swap

65.

To parallelize loops using OpenMP:

a)

#pragma omp for

b)

#pragma omp gather

c)

#pragma omp lock

d)

#pragma omp exec

66.

Tasks placed in a dispatch queue on macOS use:

a)

TBB

b)

Pthreads

c)

Grand Central Dispatch

d)

OpenCL

67.

A serial queue executes:

a)

Items in parallel

b)

Items in FIFO one at a time

c)

Based on priority only

d)

Based on thread ID

68.

A recursive computation divided into subtasks uses:

a)

Memory swapping

b)

Fork-join parallelism

c)

Single-threaded loops

d)

Paging algorithms

69.

The C++ parallel_for construct comes from:

a)

Linux kernel

b)

Windows API

c)

TBB library

d)

Java threading

70.

A cancellation that only occurs at defined points:

a)

Hard cancellation

b)

Deferred cancellation

c)

Immediate cancellation

d)

Random cancellation

71.

Delivering signals to the appropriate thread relates to:

a)

Deadlock prevention

b)

Paging

c)

Signal handling

d)

Stack overflow

72.

clone() creates threads in:

a)

Windows

b)

Linux

c)

Solaris only

d)

RTOS only

73.

TLS stores:

a)

Shared values

b)

Per-thread values

c)

Kernel-only values

d)

Process-wide constants

74.

pthread_testcancel() is an example of:

a)

A. A locking primitive

b)

B. A cancellation point

c)

C. A clone operation

d)

D. A memory handler

75.

Scheduler activations deliver:

a)

Signals from users to kernel

b)

User notifications

c)

Upcalls from kernel to thread library

d)

Debug output

76.

Java thread pools created via Executors are:

a)

Explicit threading

b)

Implicit threading

c)

Hardware threads

d)

Kernel threads

77.

#pragma omp parallel instructs compiler to:

a)

Force a single thread

b)

Create threads equal to CPU cores

c)

Disable threading

d)

Bind threads to memory

78.

In a multithreaded server, the first step is usually:

a)

Thread termination

b)

Client request arrival

c)

Load balancing

d)

Deadlock resolution

79.

The combined register set and stacks of a thread represent:

a)

Process descriptor

b)

Thread context

c)

Kernel buffer

d)

Execution shadow

80.

79. M:1 cannot use multicore because:

a)

No registers exist

b)

Only one kernel thread runs

81.

Which benefit is most relevant for CPU-intensive workloads?

a)

Economy

b)

Scalability

c)

Small memory footprint

d)

Fewer interrupts

82.

Concurrency without parallelism occurs when:

a)

Multiple cores run code

b)

A single core switches tasks

c)

Many tasks are queued

d)

No threads exist

83.

Which threading model is least commonly used today?

a)

M:M

b)

M:1

c)

1:1

d)

Two-level

84.

worker.join() in Java:

a)

Starts thread

b)

Waits for its completion

c)

Cancels thread instantly

d)

Returns thread priority

85.

A GCD concurrent queue:

a)

Runs one item at a time

b)

Can run multiple items concurrently

c)

Cancels tasks automatically

d)

Creates new processes

86.

Choosing which thread receives a signal relates to:

a)

Scheduling

b)

Signal semantics

c)

Memory management

d)

Paging

87.

A normal exit, A type of mutex lock, A directory update

a)

A. A normal exit

b)

B. Forced termination before completion

c)

C. A type of mutex lock

d)

D. A directory update

88.

Thread pools wait for:

a)

Swaps

b)

Kernel interrupts

c)

Tasks

d)

Paging signals

89.

GCD assigns tasks to:

a)

User-level threads only

b)

Available kernel threads

c)

Disk scheduler

d)

Memory queue

90.

Fork-join results combine during:

a)

Fork phase

b)

Memory allocation

c)

Join phase

d)

Blocking

91.

RecursiveTask:

a)

Returns no value

b)

Returns a value

c)

Must be serial

d)

Cannot fork

92.

OpenMP identifies parallel sections using:

a)

parallel regions

b)

exec sections

c)

sync blocks

d)

atomic blocks

93.

Kernel-mode thread data is stored in:

a)

PCB

b)

ETHREAD

c)

KTHREAD

d)

TEB

94.

TBB parallel_for is designed to:

a)

Restart CPU core

b)

Replace recursion

c)

Parallelize loop iterations

d)

Manage files

95.

TLS persists across:

a)

Process terminations

b)

Function calls within a thread

c)

OS restarts

d)

Kernel rebuilds

96.

M:M allows OS to:

a)

Disable user threads

b)

Choose number of kernel threads

c)

Prevent concurrency

d)

Duplicate processes

97.

If all user threads block when one blocks, the system is:

a)

1:1

b)

M:M

c)

Two-level

d)

M:1

98.

Linux thread behavior is set via:

a)

CreateThread()

b)

TaskPool()

c)

clone() flags

d)

Ring buffer

99.

Debugging explicit threads becomes difficult due to:

a)

Stable thread state

b)

Reduced correctness from complexity

c)

Static memory mapping

d)

No concurrency

100.

A thread pool improves performance when:

a)

Threads rarely run

b)

Threads must be recreated each time

c)

Many small tasks must execute