Fix multithread awaking.

This commit is contained in:
tuyuyang
2024-06-23 08:59:51 +08:00
parent c2e21257d0
commit 99899900a1
42 changed files with 56 additions and 37 deletions

View File

@@ -179,6 +179,19 @@ static void _dealloc_task_cb(struct Thread* task)
/* free memspace if needed to */
if (task->memspace != NULL) {
// awake deamon in this memspace
if (task->memspace->thread_to_notify != NULL) {
if (task->memspace->thread_to_notify != task) {
if (task->memspace->thread_to_notify->state == BLOCKED) {
xizi_task_manager.task_unblock(task->memspace->thread_to_notify);
} else {
task->memspace->thread_to_notify->advance_unblock = true;
}
} else if (task->memspace->thread_to_notify == task) {
task->memspace->thread_to_notify = NULL;
}
}
doubleListDel(&task->memspace_list_node);
/* free memspace if thread is the last one using it */
if (IS_DOUBLE_LIST_EMPTY(&task->memspace->thread_list_guard)) {