forked from ICLDisco/parsec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a race condition in DTD for the local termdet
DTD uses termination_detected() to destroy the taskpool, and on_leave_wait() to reset the taskpool and reinitialize the termination detector. The 'local' termination detector module had a race condition: it would mark the taskpool as 'terminated', then call the termination_detected() callback. As any thread can detect the termination, a worker thread could enter taskpool destruction in parallel with the main thread calling on_leave_wait() because taskpool_state() has returned TERMINATED already. Thus, the taskpool could be destroyed *after* its termination detector is reset, leading to asserts. Proposed solution consists of adding an intermediary state in the termination detector, 'TERMINATING'. TERMINATING is shown as 'BUSY' to the scheduler, so the main thread does not return from the main loop and does not call on_leave_wait() while the thread that detected termination is still executing termination_detected(). TERMINATING is still a necessary intermediary step in order to ensure that only one thread calls termination_detected(). Solves issue ICLDisco#634
- Loading branch information
Showing
1 changed file
with
37 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters