From: John Hodge Date: Sun, 7 Aug 2011 03:44:53 +0000 (+0800) Subject: Kernel - Updated thread code to add new active tasks to the end of the queue X-Git-Tag: rel0.10~6 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d4e3d74bb9ed79be25604e30231cd64e7091fdc2;p=tpg%2Facess2.git Kernel - Updated thread code to add new active tasks to the end of the queue - Also halved the default quantum - To improve responsiveness --- diff --git a/Kernel/threads.c b/Kernel/threads.c index c4169fec..4ab76ff6 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -7,6 +7,7 @@ #include #include #include +#include #include // Configuration @@ -23,7 +24,7 @@ #define SCHEDULER_TYPE SCHED_RR_PRI // === CONSTANTS === -#define DEFAULT_QUANTUM 10 +#define DEFAULT_QUANTUM 5 #define DEFAULT_PRIORITY 5 #define MIN_PRIORITY 10 const enum eConfigTypes cCONFIG_TYPES[] = { @@ -861,13 +862,23 @@ void Threads_AddActive(tThread *Thread) Thread->Status = THREAD_STAT_ACTIVE; // Thread->CurCPU = -1; // Add to active list - #if SCHEDULER_TYPE == SCHED_RR_PRI - Thread->Next = gaActiveThreads[Thread->Priority]; - gaActiveThreads[Thread->Priority] = Thread; - #else - Thread->Next = gActiveThreads; - gActiveThreads = Thread; - #endif + { + tThread *tmp, *prev = NULL; + #if SCHEDULER_TYPE == SCHED_RR_PRI + for( tmp = gaActiveThreads[Thread->Priority]; tmp; prev = tmp, tmp = tmp->Next ); + if(prev) + prev->Next = Thread; + else + gaActiveThreads[Thread->Priority] = Thread; + #else + for( tmp = gActiveThreads; tmp; prev = tmp, tmp = tmp->Next ); + if(prev) + prev->Next = Thread; + else + gActiveThreads = Thread; + #endif + Thread->Next = NULL; + } // Update bookkeeping giNumActiveThreads ++;