Concurrency Flashcards
What’s the main difference between threads and processes?
Threads of the same process share the same address space
Allowing multiple threads within the same process to share the same address space allows the threads to be…
independent of each other
What do the threads within a process share?
Process ID
Address space
Open files
Other resources
What does each thread within a process have, that it doesn’t share?
Thread ID
Set of registers - including PC
Stack
Give the definition:
A thread where an API specifies the behaviour of its library
POSIX thread - Pthread
What sort of results can concurrency lead to?
Non-deterministic results - different results despite the same input
Give the definition:
When multiple threads of execution update the shared data structure, and the final result depends on the execution order
Race condition
Give the definition:
An operation that completes in its entirety without worrying about interruption by any other potentially conflict-causing threads
Atomic operation
What do we call the problem that is to ensure that when one thread is executing in its critical section, no other thread is allowed to execute in that critical section?
The critical section problem
Give the definition:
A piece of code that accesses a shared resource, usually a variable or data structure
Critical section
What is the solution to the critical section problem?
Mutual exclusion
Give the definition:
A part of the solution to the critical section problem where only one thread is allowed in the critical section at a time
Mutual exclusion
Give the definition:
A part of the solution to the critical section problem where if there are several simultaneous requests from threads, must allow one to proceed
Progress
What sort of “freedom” does the progress part of the solution to the critical section problem give?
Deadlock-free
Give the definition:
A part of the solution to the critical section problem where one must eventually allow each waiting thread to enter
Bounded
What sort of “freedom” does the bounded part of the solution to the critical section problem give?
Starvation-free