1/32
Flashcards covering key concepts from concurrency and multi-threading topics in computer science.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Once we have multiple _____ within a process, the order in which things happen is no longer entirely __________.
threads, deterministic
The basic abstraction introduced for concurrency is that of a(n) __________, which breaks the classic view of a single point of execution within a program.
thread
Code that accesses shared data in a multi-threaded program is known as a(n) __________.
critical section
Each thread in a process keeps separate _____ information, including the __________ register (which keeps track of where the program is fetching instructions from).
state, PC
All of a thread's state information is saved in a(n) _____ ______ ______, similar to the ______ ______ _______ stored for each process.
Thread Control Block, Process Control Block
Without some intentional control, multi-threaded access to shared data will lead to a(n) __________, where the results depend on the timing of the code's execution.
race condition
In multi-threaded programs, we often want some chunk of code to execute __________, without being pre-empted before completing.
atomically
__________ keeps two (or more threads) from accessing shared data at the same time, avoiding race conditions.
mutual exclusion
All threads in a process share both code and the _____ section of memory, but each thread has its own __________ (often called thread-local storage).
heap, stack
To facilitate the writing of correctly-functioning concurrent programs, the _______ provides a few useful instructions we can use to build __________ primitives, which threads can then use to coordinate access to shared resources.
hardware, synchronization
The threading API analogous to fork() is called _____ _____.
pthread_create()
Unlike a fork call, the function that creates a new thread takes a(n) __________ as an argument.
function pointer
The most basic way of accomplishing mutual exclusion when using the pthread library is to create a(n) __________, which is a variable of type __________.
mutex, pthread_mutex
Because C lacks native support for generics, the thread creation function both accepts and returns a(n) __________.
void pointer
The threading API analogous to wait() is called __________.
pthread_join()
Using a separate lock for each separate shared resource is a __________ locking strategy that can increase concurrency.
fine-grained
Above all else, a locking mechanism must guarantee __________. Otherwise, it might allow multiple threads to enter a critical section simultaneously.
mutual exclusion
To use locks in a multi-threaded program, you first declare a(n) __________ variable. For the simplest type of POSIX lock, it would be of type pthread ______
lock, mutex
You can guarantee that a block of instructions will execute __________ by disabling ______ before starting its execution.
atomically, interrupts
When moving a thread from the _______ state to the blocked state due to an unavailable lock, the OS has to add the thread to a(n) __________ so it gets a fair chance to run when the lock becomes available.
running, queue
In general, spin locks pass the _______ criterion for locking, but fail miserably in the areas of __________ and performance.
correctness, fairness
When no thread is in its corresponding ______ section, the lock is said to be __________.
critical, free
Constantly polling a flag until its value changes is called __________. It's effective but not efficient.
spin-waiting
The test-and-set instruction is often known as the __________ instruction, since it swaps the contents of a register with the contents of a memory location in a single instruction.
atomic exchange
In the context of locking, _______ means giving each thread contending for the lock a chance at acquiring it once it's free. On the other hand, if a thread never gets a chance to run, it's said to be suffering from __________.
fairness, starvation
To avoid spin waiting, a thread can voluntarily move itself from the _________ state to the __________ state by calling yield().
running, ready
Having one big lock that is used any time any critical section is accessed is be a __________ locking strategy, which can lead to inefficiency.
coarse-grained
As an alternative to spin waiting, the function that acquires a lock can move the calling thread from the _______ state to the __________ state, where it doesn't take up any CPU time until the lock becomes available.
running, blocked
When a ______ is in the critical section guarded by a particular lock, that lock should be______ by that thread.
thread, held
Every ________ section in a multi-threaded program needs to be 'protected' by a(n) __________, which provides mutual exclusion.
critical, lock
The simplest type of POSIX lock is called a(n) __________ because it is used to provide mutual exclusion between threads.
mutex
Instead of spin waiting, the function that acquires a lock can use the __________ system call to force a context switch if the flag it's waiting for has not yet changed.
yield()
When compiling a multi-threaded program (using GCC or Clang), you have to add the __________ command-line switch to ensure the correct library is linked, and other configuration changes are made.
pthread