From: Matthias Kruk Date: Mon, 25 Nov 2019 06:22:45 +0000 (+0900) Subject: Suspend the executing task, if the caller of sched_task_suspend() is attempting to... X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=57530ebfa537fca2fa0ccd2f8b5629f99c159042;p=corax Suspend the executing task, if the caller of sched_task_suspend() is attempting to suspend itself --- 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); }