Parallel Computing
- 49Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
If one person takes 10 days to complete a job, how long would 10 people take if they divide the work evenly and work in parallel?
If one person takes 10 days to complete a job, how long would 10 people take if they divide the work evenly and work in parallel?
49 questions
- 1
If one person takes 10 days to complete a job, how long would 10 people take if they divide the work evenly and work in parallel?
- A
Two days
- B
Five days
- C
One day
- D
Ten days
Correct answer
COne day
Explanation
Each person can complete one-tenth of the job in 10 days, so the ten portions can be completed together in one day.
- A
- 2
What is the main purpose of parallelization in a computer system?
- A
To replace a program's instructions with a smaller set of instructions
- B
To ensure that every computing entity executes the entire job independently
- C
To divide a large job among computing entities that work simultaneously
- D
To make one computing entity perform every part of a job in sequence
Correct answer
CTo divide a large job among computing entities that work simultaneously
Explanation
Parallelization divides a larger job into smaller portions that computing entities can execute at the same time, reducing completion time.
- A
- 3
Why can a GPU help complete certain large jobs quickly?
- A
It can perform thousands of small tasks in parallel
- B
It guarantees that each task uses a different process
- C
It assigns every task to a separate operating system
- D
It eliminates the need to divide work into smaller tasks
Correct answer
AIt can perform thousands of small tasks in parallel
Explanation
The content describes GPUs as hardware capable of performing thousands of tasks in parallel, with each task contributing a small part of a larger job.
- A
- 4
A program runs as one process on a system with four processors. What may happen if the process contains only one sequential execution path?
- A
It may run on one processor while the other processors remain unused by that program
- B
It automatically divides itself into four independent processes
- C
It alternates each instruction among all four processors
- D
It must run on all four processors because they are available
Correct answer
AIt may run on one processor while the other processors remain unused by that program
Explanation
The scheduler may assign the single process to one processor. Without parallel execution paths, the program does not automatically use all four processors for its work.
- A
- 5
How does dividing a 10-million-number summation among four workers enable parallel work?
- A
Each worker sums the complete range independently
- B
Each worker sums a distinct quarter of the range
- C
Each worker waits for the previous worker to finish the full range
- D
Each worker handles one number while the others remain idle
Correct answer
BEach worker sums a distinct quarter of the range
Explanation
The example divides the numbers into four sets of 2.5 million, so each worker can calculate a separate partial sum.
- A
- 6
If four equally sized portions of a job run at the same time on four processors, what speedup does the example expect?
- A
The job must finish twice as fast
- B
The job takes four times longer
- C
The job may finish four times faster
- D
The job's completion time cannot change
Correct answer
CThe job may finish four times faster
Explanation
The example suggests that four processors handling four equal portions in parallel could complete the overall job four times faster.
- A
- 7
Which sequence describes how the example program becomes a running process?
- A
A processor turns source code directly into a thread without an executable
- B
The scheduler creates an executable, which a compiler runs as a process
- C
A compiler creates an executable, which is then run to create a process
- D
A process creates the compiler, which then generates an operating system
Correct answer
CA compiler creates an executable, which is then run to create a process
Explanation
The described sequence is to compile the program, such as with gcc, to produce an executable and then run that executable to create a process.
- A
- 8
Why might a process sometimes run on a different processor from the one to which it was initially assigned?
- A
Its memory space is automatically copied into a new process
- B
The process may migrate to another processor during execution
- C
Its instructions are replaced whenever the scheduler runs
- D
It must move processors after every function call
Correct answer
BThe process may migrate to another processor during execution
Explanation
The content notes that a process may rarely migrate to another processor, although the example sets that possibility aside.
- A
- 9
In the process-based version of the summation example, how many fork system calls are needed to create four worker processes?
- A
Two
- B
Eight
- C
One
- D
Four
Correct answer
DFour
Explanation
The example states that creating the four processes requires four fork system calls, with each call creating one process.
- A
- 10
What is a key memory property of the four processes used in the process-based approach?
- A
Each shares its entire memory map with every other process
- B
Only the first process has instructions, data, heap, and stack
- C
All four necessarily use one shared stack and one shared heap
- D
Each has its own instructions, data, heap, and stack
Correct answer
DEach has its own instructions, data, heap, and stack
Explanation
Processes are isolated execution entities, each with its own instructions, data, heap, and stack.
- A
- 11
Why do separate worker processes need an interprocess communication mechanism to exchange results?
- A
The operating system prevents processes from returning values
- B
They cannot execute on different processors
- C
Their memory spaces are isolated from one another
- D
They do not have their own instructions
Correct answer
CTheir memory spaces are isolated from one another
Explanation
Because each process has an isolated memory space, processes need IPC techniques to communicate with one another.
- A
- 12
Which pair of approaches is identified as a way for processes to communicate?
- A
Thread stacks, or processor migration
- B
Register saving, or changing the active page table
- C
Message passing with send and receive, or shared memory
- D
Function calls, or the compiler's executable output
Correct answer
CMessage passing with send and receive, or shared memory
Explanation
The content describes IPC through send-and-receive message passing and through shared memory created using system calls.
- A
- 13
How does the operating system participate in the described send-and-receive IPC method?
- A
It changes each message into a separate executable
- B
It helps create a channel through which processes communicate
- C
It combines the processes into one shared execution context
- D
It copies each process's stack into the sender's registers
Correct answer
BIt helps create a channel through which processes communicate
Explanation
For message passing, the operating system helps create a channel that enables communication between processes.
- A
- 14
Why do process creation, destruction, and file operations involve system calls?
- A
They are operations that can only be performed by a thread stack
- B
These are process-management activities handled through operating-system services
- C
They are forms of parallel work that require a separate processor
- D
They are instructions that every process must copy into its heap
Correct answer
BThese are process-management activities handled through operating-system services
Explanation
The content identifies process creation, destruction, and file operations as management activities carried out through system calls.
- A
- 15
What happens when a process invokes a system call, according to the described mechanism?
- A
The process immediately turns into a thread without operating-system involvement
- B
The processor duplicates the process's data and resumes without a handler
- C
A software trap triggers operating-system execution and the relevant handler runs
- D
The system call is executed only after all other processes terminate
Correct answer
CA software trap triggers operating-system execution and the relevant handler runs
Explanation
A system call causes a software trap, after which the operating system identifies the call and executes its corresponding handler.
- A
- 16
Why can using several similar processes create unnecessary duplication?
- A
The processes may repeat the same instructions and access the same data
- B
Each process performs only operating-system work rather than the job
- C
Each process must use a different program and different global data
- D
The processes share all of their memory, so every instruction is skipped
Correct answer
AThe processes may repeat the same instructions and access the same data
Explanation
The example notes that processes doing similar work can duplicate instructions and data, such as a shared array or global data.
- A
- 17
What is the central idea of using threads instead of four processes for the summation?
- A
Use one process containing four execution entities that divide the work
- B
Use one thread that performs four sequential copies of the entire job
- C
Use four processes, each containing a separate copy of the operating system
- D
Use four processors without creating any execution entities
Correct answer
AUse one process containing four execution entities that divide the work
Explanation
The thread-based approach creates one process and four threads within it, with each thread handling one quarter of the work.
- A
- 18
Which description best captures how threads within one process share resources?
- A
They share the process's code, global data, heap, and open files
- B
They share only their stacks, while keeping separate heaps and code
- C
They share the processor but cannot access the process's data
- D
They each have separate copies of the process's code and global data
Correct answer
AThey share the process's code, global data, heap, and open files
Explanation
Threads in one process share its code, global data, heap, and open files.
- A
- 19
Which resource distinguishes one thread from another within the same process?
- A
Its own set of open files
- B
Its own copy of the global data segment
- C
Its own process-wide heap
- D
Its own stack
Correct answer
DIts own stack
Explanation
Each thread has its own stack, while the threads share the process's code, data, heap, and open files.
- A
- 20
Why does each thread need its own stack?
- A
The stack supports thread-specific local variables and function-call information
- B
The stack stores the process's shared global data for all threads
- C
The stack gives the thread a separate copy of every open file
- D
The stack lets the thread execute without being attached to a process
Correct answer
AThe stack supports thread-specific local variables and function-call information
Explanation
A thread's own stack provides space for its local variables and information about its function calls.
- A
- 21
What is included in a thread's execution context as described in the content?
- A
A separate process identifier, heap, and complete page table
- B
Register values, including the EIP and ESP, along with its stack
- C
The code segment and every other thread's stack
- D
Only the shared global data and open files of the process
Correct answer
BRegister values, including the EIP and ESP, along with its stack
Explanation
The thread's execution context includes its stack and register values, with EIP and ESP given as examples of registers.
- A
- 22
How can threads in one process be scheduled on a multiprocessor system?
- A
They must each create a separate process before being scheduled
- B
They must all run on the same processor at the same time
- C
They can run only on the processor that first ran the process
- D
They may run on different processors or take turns on the same processor
Correct answer
DThey may run on different processors or take turns on the same processor
Explanation
Threads may be scheduled on different processors, or multiple threads may take turns running on the same processor at different times.
- A
- 23
Which statement correctly describes the relationship between a thread and a process?
- A
A thread must belong to a process, while a process can execute with one thread
- B
A process must belong to a thread, while a thread can execute alone
- C
A thread and a process are both independent of any other execution entity
- D
A process cannot execute unless it contains at least four threads
Correct answer
AA thread must belong to a process, while a process can execute with one thread
Explanation
A thread cannot execute on its own and must be attached to a process. A process can execute with a single thread.
- A
- 24
What happens to a process's threads when the process terminates?
- A
All threads belonging to that process also terminate
- B
The threads move automatically into another process
- C
The threads continue running as independent processes
- D
Only the thread with the lowest identifier terminates
Correct answer
AAll threads belonging to that process also terminate
Explanation
Threads depend on their process, so termination of the process also terminates all its threads.
- A
- 25
What happens when one thread terminates but its process remains active?
- A
The entire process must terminate, but the thread's stack remains in use
- B
All remaining threads become separate processes with copied stacks
- C
The remaining threads can continue, and the terminated thread's stack is reclaimed
- D
The process must restart every thread before doing any further work
Correct answer
CThe remaining threads can continue, and the terminated thread's stack is reclaimed
Explanation
A thread can terminate while the process and its other threads continue. The terminated thread's stack is reclaimed.
- A
- 26
What comparison does the example give for creating 50,000 processes versus 50,000 threads on one machine?
- A
Creating the processes took 8.1 units of time, while creating the threads took 0.9
- B
Creating the processes took 0.9 units of time, while creating the threads took 8.1
- C
Both creation operations took 8.1 units of time
- D
Both creation operations took 0.9 units of time
Correct answer
ACreating the processes took 8.1 units of time, while creating the threads took 0.9
Explanation
For one machine in the comparison, creating 50,000 processes took 8.1 units of time, while creating 50,000 threads took 0.9, illustrating the lower creation cost of threads.
- A
- 27
Why is communication between threads in the same process usually simpler than communication between separate processes?
- A
Threads communicate only by changing the active page table
- B
Threads have separate memory spaces that require no coordination
- C
Threads can communicate through shared global data or the shared heap
- D
Threads automatically send operating-system messages for every variable
Correct answer
CThreads can communicate through shared global data or the shared heap
Explanation
Threads in one process can access its shared global data and heap, allowing communication without the IPC mechanisms needed between isolated processes.
- A
- 28
Why can process-based message passing add communication overhead?
- A
Each message requires a separate processor to be created
- B
Each send operation duplicates every process's stack
- C
Each send and receive operation is a system call
- D
Message passing prevents the operating system from running
Correct answer
CEach send and receive operation is a system call
Explanation
The content notes that send and receive operations for message-passing IPC are system calls and therefore have overhead.
- A
- 29
Why can setting up shared-memory IPC between processes still involve overhead?
- A
Shared memory requires every process to use a separate thread stack
- B
Creating and managing the shared memory requires system calls
- C
Shared memory cannot be used for communication between processes
- D
Processes must duplicate all instructions after each shared-memory access
Correct answer
BCreating and managing the shared memory requires system calls
Explanation
Although shared memory enables communication, creating and managing it between processes is done through system calls and has overhead.
- A
- 30
Why can switching between threads of one process be faster than switching between processes?
- A
A thread switch always terminates the previously running thread
- B
Threads have no execution context and require no register values
- C
A thread's context is smaller, so less state needs to be saved and restored
- D
Process switching never involves saving any execution state
Correct answer
CA thread's context is smaller, so less state needs to be saved and restored
Explanation
A thread has a smaller execution context than a process, so switching between threads requires saving and restoring less state.
- A
- 31
What memory-management advantage can a context switch between threads in one process have?
- A
The operating system must replace the process's code segment
- B
The thread switch requires every TLB entry to be discarded
- C
Each thread activates a newly created page table
- D
The same page tables remain active, so a page-table change is unnecessary
Correct answer
DThe same page tables remain active, so a page-table change is unnecessary
Explanation
Threads in the same process use the same process page tables, so switching between them does not require changing the active page tables.
- A
- 32
How does keeping the same page tables during a thread switch affect the TLB?
- A
Cached TLB entries can remain valid because the address space has not changed
- B
The TLB becomes unnecessary because threads have no memory accesses
- C
The TLB must be flushed whenever a thread changes its stack
- D
Every cached TLB entry must be replaced by entries from another process
Correct answer
ACached TLB entries can remain valid because the address space has not changed
Explanation
Since the threads share one process address space, the page tables do not change during a thread switch, so cached TLB entries remain valid.
- A
- 33
Which contrast between a process and a thread is accurate?
- A
A thread has its own heap and data, while its process shares the thread's stack
- B
A process shares its code with other processes, while a thread owns separate code
- C
A process and each of its threads have entirely separate memory maps
- D
A process has its own data and heap, while its threads use those shared process regions
Correct answer
DA process has its own data and heap, while its threads use those shared process regions
Explanation
A process has its own memory regions, including data and heap; threads within it share those process regions but have their own stacks.
- A
- 34
Which function is used by the pthread library to create a thread?
- A
pthread_exit
- B
pthread_create
- C
pthread_join
- D
fork
Correct answer
Bpthread_create
Explanation
The pthread library uses pthread_create to create a new thread context in a process.
- A
- 35
What is the purpose of the first argument to pthread_create?
- A
To provide the return value of a thread that has exited
- B
To specify the function that the new thread will execute
- C
To select the processor on which the thread must run
- D
To provide a location for the new thread's identifier
Correct answer
DTo provide a location for the new thread's identifier
Explanation
The first argument is a pointer to a pthread_t variable that receives the newly created thread's identifier, or TID.
- A
- 36
What information can the attributes argument to pthread_create specify?
- A
The return status of a thread that has already exited
- B
The final sum computed by the thread
- C
The process identifier of the calling process
- D
Properties of the thread being created
Correct answer
DProperties of the thread being created
Explanation
The attributes argument can specify various properties of the thread being created.
- A
- 37
What does the start-routine argument to pthread_create identify?
- A
A function from which the new thread begins executing
- B
A system call that destroys the calling process
- C
A shared-memory channel between two processes
- D
A thread identifier to wait for before creating the thread
Correct answer
AA function from which the new thread begins executing
Explanation
The start routine is a function pointer, and the newly created thread begins execution in that function.
- A
- 38
What is the role of the final argument to pthread_create?
- A
It provides the argument passed to the start-routine function
- B
It stores the thread's identifier after the thread exits
- C
It selects the thread's private heap
- D
It specifies which process will be terminated
Correct answer
AIt provides the argument passed to the start-routine function
Explanation
The final argument is a pointer to the arguments supplied to the start routine.
- A
- 39
Which pthread function is used to terminate a thread and provide its return status?
- A
pthread_create
- B
pthread_exit
- C
pthread_join
- D
send
Correct answer
Bpthread_exit
Explanation
A thread can use pthread_exit to terminate and pass a pointer to its return value or status.
- A
- 40
What does pthread_join do when given a thread identifier?
- A
It blocks the calling thread until the specified thread exits
- B
It creates a new thread with the specified identifier
- C
It immediately terminates the specified thread
- D
It copies the specified thread's stack into the calling thread
Correct answer
AIt blocks the calling thread until the specified thread exits
Explanation
pthread_join waits for the thread identified by its argument; the calling thread blocks until that thread exits.
- A
- 41
After the thread specified to pthread_join exits, what can the calling thread obtain?
- A
A new process identifier for the exited thread
- B
The exited thread's status or return value
- C
The processor's next scheduling decision
- D
A separate copy of the exited thread's heap
Correct answer
BThe exited thread's status or return value
Explanation
When the specified thread exits, pthread_join completes and can provide the thread's exit status.
- A
- 42
In the four-thread summation example, why are four pthread_t variables declared?
- A
To hold the identifiers of the four created threads
- B
To provide four separate heaps for the process
- C
To identify four different start-routine functions
- D
To store the four partial sums before they are calculated
Correct answer
ATo hold the identifiers of the four created threads
Explanation
The variables t1, t2, t3, and t4 are used by pthread_create to receive the identifiers of the four newly created threads.
- A
- 43
In the example, what does passing a different argument to each thread's start routine accomplish?
- A
It assigns each thread a separate process and address space
- B
It gives each thread a different copy of the program's code
- C
It tells each thread which other thread must terminate first
- D
It lets the shared routine identify which portion of the numbers that thread should sum
Correct answer
DIt lets the shared routine identify which portion of the numbers that thread should sum
Explanation
Each thread runs the same start routine, but its argument identifies its portion of the summation work.
- A
- 44
What does the example's global sum array store?
- A
The return status of the main process
- B
A separate partial sum computed by each thread
- C
A separate process identifier for each worker
- D
A copy of every number in the full range
Correct answer
BA separate partial sum computed by each thread
Explanation
The global array has four elements, and each thread stores its partial sum in the element assigned to it.
- A
- 45
Why can the four threads write their partial sums to the shared global array?
- A
The operating system merges separate process arrays automatically
- B
Each thread has a private copy of the global array
- C
Threads in one process can access that process's global data
- D
The array is stored only in the thread identifiers
Correct answer
CThreads in one process can access that process's global data
Explanation
Threads in one process share access to the process's global data, allowing each to write its result to the shared array.
- A
- 46
Why does the main thread call pthread_join for each worker thread?
- A
To create a replacement thread for each worker
- B
To ensure every partial sum is ready before calculating the final result
- C
To divide each partial sum into smaller portions
- D
To stop the workers before they begin their calculations
Correct answer
BTo ensure every partial sum is ready before calculating the final result
Explanation
Each join waits for its worker to finish, ensuring the partial sums are complete before the main thread adds them.
- A
- 47
How does the example produce the final sum after all worker threads finish?
- A
It adds the four partial sums stored in the shared array
- B
It repeats the full range once for each thread
- C
It adds the thread identifiers together
- D
It takes the result from only the first thread
Correct answer
AIt adds the four partial sums stored in the shared array
Explanation
Once all four joins complete, the program adds the four partial sums to obtain the sum of the full range.
- A
- 48
What is needed when compiling the pthread example with gcc, as described?
- A
The pthread library must be linked, for example with -lpthread
- B
The program must be compiled once for every thread
- C
The compiler must be replaced by the operating system scheduler
- D
The fork library must be linked instead of the pthread library
Correct answer
AThe pthread library must be linked, for example with -lpthread
Explanation
The example compiles with gcc and links the pthread library using an option such as -lpthread.
- A
- 49
Which set lists other threading libraries or library families mentioned in the content?
- A
Fork, send-and-receive, and shared memory
- B
Pthread, gcc, and the process scheduler
- C
Windows threads, Boost, and Linux threads
- D
EIP, ESP, and the translation lookaside buffer
Correct answer
CWindows threads, Boost, and Linux threads
Explanation
Besides pthreads, the content mentions the Windows threads library, Boost for C++, and Linux threads.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.