From 5951bcd83738d362de041262f95d5feda982185f Mon Sep 17 00:00:00 2001 From: EunBong Song Date: Fri, 13 Apr 2018 07:38:15 -0600 Subject: [PATCH] Change ordering of round-robin time slice check (sched_process_scheduler()) and processing of wdog timers (wd_timer()). wd_timer()'s callback function can change current running task and, hence, must be done after the time slice check. The time slice check will decrement the currently running task's time slice allotment. If such a context switch occurs, then the newly started task will lost one could of that allotment before it even has a chance to run. --- sched/sched/sched_processtimer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sched/sched/sched_processtimer.c b/sched/sched/sched_processtimer.c index 7de2a4b58f..fc71746c73 100644 --- a/sched/sched/sched_processtimer.c +++ b/sched/sched/sched_processtimer.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_processtimer.c * - * Copyright (C) 2007, 2009, 2014-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -213,13 +213,13 @@ void sched_process_timer(void) } #endif - /* Process watchdogs */ - - wd_timer(); - /* Check if the currently executing task has exceeded its * timeslice. */ sched_process_scheduler(); + + /* Process watchdogs */ + + wd_timer(); }