DeterministicSchedule support for global invariants and auxiliary variables
Summary:
Support for user-defined auxiliary variables and global invariants.
- Add two fields to DSched:
-- tls_aux: static FOLLY_TLS std::function<void(uint64_t, bool)>*. User-defined auxiliary function with parameters: count of synchronization steps, and boolean indicator of the success of the current step.
-- step_: uint64_t. Count of shared accesses that correspond to user synchronization steps (atomic accesses for now).
- Add two static functions to DSched:
-- void setAux(std::function<void(uint64_t, bool)>*).
-- void callAux(bool success). Calls the aux function with the step count and the bool success argument.
- Add a version of afterSharedAccess(bool) that takes a bool success parameter and calls callAux(success). This version is used in every atomic operation of DeterministicAtomic.
- Add direct load interface to DeterministicAtomic for use by auxiliary functions.
Note: This the base of a stacked diff with:
- Test the new capabilities in DeterministicScheduleTest.h
Next steps:
- Use the new capabilities to test dynamic MPMCQueue
Other possible additions:
- Change the implementation of DeterministicMutex to allow inspecting its internal state.
- Test the new capabilities for mutexes and semaphores in DeterministicScheduleTest.h
- Performance optimization: e.g., user-space context switching, using regular variables to implements atomics.
Reviewed By: djwatson
Differential Revision:
D3648146
fbshipit-source-id:
4f838ff7cfd41ab71cfdf22bb67def3221948311