From 57530ebfa537fca2fa0ccd2f8b5629f99c159042 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Mon, 25 Nov 2019 15:22:45 +0900 Subject: [PATCH] Suspend the executing task, if the caller of sched_task_suspend() is attempting to suspend itself --- kernel/core/sched.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/core/sched.c b/kernel/core/sched.c index 00f458f..15a8a0f 100644 --- a/kernel/core/sched.c +++ b/kernel/core/sched.c @@ -225,12 +225,14 @@ int sched_signal(pid_t pid) int sched_task_suspend(task_t *t) { + task_t *ctask; int ret_val; ret_val = -EALREADY; + ctask = task_get_current(); if(!t) { - t = task_get_current(); + t = ctask; } task_lock(t); @@ -248,5 +250,10 @@ int sched_task_suspend(task_t *t) task_unlock(t); + if(t == ctask) { + /* schedule a different task */ + sched_tick(); + } + return(ret_val); } -- 2.47.3