]> git.corax.cc Git - corax/commitdiff
sched/lazy: Fix bug in _lazy_tick() causing waiting processes to be scheduled
authorMatthias Kruk <m@m10k.eu>
Fri, 1 May 2020 01:39:36 +0000 (10:39 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 1 May 2020 01:39:36 +0000 (10:39 +0900)
kernel/sched/lazy.c

index eed982315a7170dab26fabfb11c775cc57567dbf..fb7c7beff0239ad63e249746694dc04cd40c56a4 100644 (file)
@@ -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;
                        }
                }