From: Matthias Kruk Date: Fri, 1 May 2020 01:39:36 +0000 (+0900) Subject: sched/lazy: Fix bug in _lazy_tick() causing waiting processes to be scheduled X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=7b03940676f9111caff836c3b2da13d40d305af8;p=corax sched/lazy: Fix bug in _lazy_tick() causing waiting processes to be scheduled --- diff --git a/kernel/sched/lazy.c b/kernel/sched/lazy.c index eed9823..fb7c7be 100644 --- a/kernel/sched/lazy.c +++ b/kernel/sched/lazy.c @@ -36,7 +36,16 @@ static int _lazy_tick(struct sched_lazy *lazy) } else { /* task has exhausted its time slice - reschedule */ ctask->t_rslice = ctask->t_tslice; - ctask->t_state = TASK_STATE_READY; + + /* + * This function will also be called with the intention to + * reschedule, for example because the current task has changed + * to TASK_STATE_WAITING. In such a case, we should not override + * the task state here. + */ + if(ctask->t_state == TASK_STATE_RUNNING) { + ctask->t_state = TASK_STATE_READY; + } ret_val = 1; } }