https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98738
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I've been wondering whether it wouldn't be best to pass through omp_eventhandle_t the pointer to the gomp_task rather than some particular semaphore and in omp_fulfill_event then decide based on that task, one case would be if it is the included task, then it should post a semaphore and be done with it, otherwise (not included task), it should find the corresponding team (which might not be necessary the omp_fulfill_event's task), lock the task_lock and figure out in which of the many cases the task is in, if not yet finished, perhaps just clear detach bool and be done with it, if in the state after that, figure out what is waiting for that task and deal with that. Not sure if a per-task semaphore is what we want in that case, e.g. we could have a taskwait, taskgroup end or barrier waiting for multiple tasks with detach clause and if that is the only thing they might be waiting on, then those should be sleeping on taskwait_sem, taskgroup_sem or on the barrier, so depending on what they are sleeping on that should be awaken.