From: Alan Cox Date: Sun, 4 Dec 2016 13:37:54 +0000 (+0000) Subject: process: changes for IRQ when swapping X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e6041664d53dc3787c7f3b71cacfece9ae2148b4;p=FUZIX.git process: changes for IRQ when swapping Don't scribble on the udata when it is unsafe Don't charge time to processes when swapping them --- diff --git a/Kernel/process.c b/Kernel/process.c index 77d2c535..3b103204 100644 --- a/Kernel/process.c +++ b/Kernel/process.c @@ -331,8 +331,10 @@ void load_average(void) void timer_interrupt(void) { - /* Increment processes and global tick counters */ - if (udata.u_ptab->p_status == P_RUNNING) { + /* Increment processes and global tick counters. We can't do this + mid swap because we might have half of the bits for one process + and half of another.. */ + if (!inswap && udata.u_ptab->p_status == P_RUNNING) { if (udata.u_insys) udata.u_stime++; else @@ -368,10 +370,10 @@ void timer_interrupt(void) #endif } #ifndef CONFIG_SINGLETASK - /* Check run time of current process */ - /* Time to switch out? */ - /* FIXME: don't count runticks while swapping in ! */ - if ((++runticks >= udata.u_ptab->p_priority) + /* Check run time of current process. We don't charge time while + swapping as the last thing we want to do is to swap a process in + and decide it took time to swap in so needs to go away again! */ + if (!inswap && (++runticks >= udata.u_ptab->p_priority) && !udata.u_insys && inint && nready > 1) { need_resched = 1; #ifdef DEBUG_PREEMPT