Race Conditions & Locks Flashcards
Mutual Exclusion
limits access to a shared resource to one thread at a time; guarantees atomicity!!!
Race Condition
condition where incorrect program output may be generated depending on the interleaving of instructions from multiple threads
Critical section
the section of code that accesses shared resources
Locks
thread synchronization mechanism that achieves mutual exclusion
Atomic operation
program operations that run completely independently of any other processes
Synchronization
a mechanism to ensure multiple loci do not simultaneously access the shared resources
Shared Resource
anything of interest; represented in memory, so we can talk in terms of shared variables
What is a deterministic ?
for the same input, the same output
Correct output
any output from interleaving mutltiple threads is the same as an output from executing the threads sequentially; whatever output threads execute sequentially
Atomicity of critical section
only one thread is in the critical section, and that thread must finish before another enters the critical section
Benefits of synchronization
what you can do when outside of the bits where you are forced to be synchronised, and that other threads are free to go about their business if they aren’t accessing that variable
Atomic Code
code that is executed by a thread invisibly from the point of view of other threads trying to execute the same code;