Threads and Data
Races can occur when threads operate on shared data.
When is data shared?
- local variables are private
addressed off the stack, e.g., as @(SP+offset)
not shared, since each thread has its own stack pointer (SP)
never export (pass/share/store) a pointer to a local variable
- global variables and static objects are shared
addressed with absolute addresses
- dynamic objects or other heap data are shared
allocated from global storage with new/delete, or malloc/free