You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change the implementation of mutex to test and set
1. Directly show the scenarios using Test and Set and
its atomic operations.
- Use `atomic_flag_test_and_set()` and `atomic_flag_clear()` to
implement the original mutex lock and unlock mechanism.
- Replace the original condition variable wait mechanism with
`atomic_flag_test_and_set()` combined with a `while` loop.
2. Avoid deadlock in `tpool_future_get()`.
- The main thread must first wait for the worker to complete the "BBP
formula" job.
- Subsequently, it should wait for the worker to unlock.
- These two operations must occur in this order to avoid deadlock.
Swapping them will lead to deadlock.
0 commit comments