Parallel Computing
- 44Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is parallelization in computing?
Dividing a large job into smaller tasks that execute at the same time on different computing entities.
Or swipe the card
44 cards
What is parallelization in computing?
Dividing a large job into smaller tasks that execute at the same time on different computing entities.
How does the example of ten people doing a job illustrate parallelization?
If the work can be divided evenly, ten people can each do one-tenth of it at the same time, completing it in about one day instead of ten.
Why can a program running on a four-processor system still use only one processor?
A single sequential execution may be scheduled on one processor, leaving the others idle or available for other tasks.
How could summing ten million numbers be divided among four workers?
Give each worker a distinct quarter of the range—about 2.5 million numbers—and have each compute a partial sum.
What speedup might ideally result from dividing a job evenly across four processors?
The job might finish about four times faster.
What hardware is described as capable of performing thousands of tasks in parallel?
Graphics processing units (GPUs).
How can multiple processes be used to parallelize a job?
Create separate processes, assign each a portion of the work, and schedule them to run on different processors.
What system call is used in the example to create each process?
The
forksystem call.What memory and program resources does a process have independently of other processes?
Its own instructions, data, heap, and stack.
Why do separate processes generally need interprocess communication (IPC) to share information?
Their memory spaces are isolated, so they cannot simply access one another's data.
What are two IPC approaches described for communication between processes?
Message passing with send and receive operations, and shared memory.
Why can using multiple processes introduce overhead when parallelizing a job?
Process creation, management, and communication involve system calls, and separate processes may duplicate instructions and data.
What is a thread?
A lightweight execution entity that runs within a process.
Which resources are shared among threads in the same process?
The process's code, global data, heap, and opened files.
Which important resource does each thread have independently?
Its own stack.
Can a thread execute independently of a process?
No. A thread must be attached to a process to execute.
What happens to a process's threads when the process terminates?
All of its threads terminate.
What happens to the other threads if one thread terminates while its process continues?
The other threads can continue executing.
How can threads be scheduled on processors?
They can run on different processors in parallel or take turns on the same processor at different times.
What information does a thread's execution context include?
Register values and its stack, including register state such as the instruction pointer and stack pointer.
How can threads in one process communicate efficiently?
They can communicate through shared global data or the shared heap.
Why is creating threads generally more efficient than creating processes?
Threads are lightweight and can be created and managed with less overhead than processes.
What did the example benchmark report for creating 50,000 processes versus 50,000 threads on one machine?
It reported 8.1 time units for processes and 0.9 for threads.
Why does thread communication usually have less overhead than process communication?
Threads in one process can use shared data, whereas processes typically communicate through IPC mechanisms that require system calls.
Why can switching between threads be faster than switching between processes?
A thread has a smaller context to save and restore, and threads in the same process use the same page tables.
What happens to page tables and TLB entries when switching between threads of the same process?
The page tables remain the same, so valid cached TLB entries can remain useful.
How does a process's memory ownership differ from a thread's?
A process has its own code, data, heap, and stack; a thread shares its process's code, data, and heap but has its own stack.
What are the main lifecycle functions provided by the pthread library?
pthread_create,pthread_exit, andpthread_join.What does the first argument to
pthread_createprovide?A pointer to a
pthread_tvariable that receives the new thread's identifier.What is the purpose of the attributes argument to
pthread_create?It specifies properties of the thread being created.
What does the start-routine argument to
pthread_createspecify?A pointer to the function where the new thread begins execution.
What is the purpose of the final argument to
pthread_create?It provides a pointer to the argument passed to the thread's start routine.
What does
pthread_exitdo, and how can it return a thread's status?It terminates the calling thread and can pass a pointer to the thread's return status.
What does
pthread_joindo?It blocks the calling thread until the specified thread exits, then allows its exit status to be obtained.
How does the pthread example divide the sum of ten million numbers?
It creates four threads, each of which sums a different quarter of the range.
What is the purpose of the four
pthread_tvariables in the parallel-sum example?They store the identifiers of the four created threads.
What does each call to
pthread_createdo in the parallel-sum example?It creates a thread in the process, records its TID, and starts it at the designated thread function.
How does the parallel-sum example tell each thread which quarter of the work to perform?
It passes a different argument to each thread; the thread uses that value as its identifier for selecting its range.
How does the example store the partial sums computed by the threads?
In separate elements of a shared global array, with one element assigned to each thread.
Why can the main thread safely combine the partial sums after four successful joins?
Each join waits for its specified worker thread to exit, so after all four joins, all four partial sums have been computed.
What work does the main thread perform while the worker threads calculate their sums?
It calls
pthread_joinfor each worker, blocking until that worker finishes.How is the pthread library linked when compiling the example with GCC?
Use the
-lpthreadlinker option, for example,gcc threads.c -lpthread.What can be compared to evaluate the speedup from using threads?
The execution time of a threaded program can be compared with versions using processes or a single sequential process.
Name three thread libraries or frameworks mentioned besides the pthread library.
Windows threads, Boost for C++, and Linux threads.

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