From: John Hodge Date: Mon, 26 Sep 2011 13:25:49 +0000 (+0800) Subject: Kernel - Added Proc_Rescedule support X-Git-Tag: rel0.11~50 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=3ae2945f389308e0fab4f63980e8152577c17bf8;p=tpg%2Facess2.git Kernel - Added Proc_Rescedule support --- diff --git a/Kernel/include/hal_proc.h b/Kernel/include/hal_proc.h index 242af204..e7ca8918 100644 --- a/Kernel/include/hal_proc.h +++ b/Kernel/include/hal_proc.h @@ -18,6 +18,7 @@ extern tTID Proc_Clone(Uint Flags); extern void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize); extern void Proc_CallFaultHandler(tThread *Thread); extern void Proc_DumpThreadCPUState(tThread *Thread); +extern void Proc_Reschedule(void); extern tPAddr MM_ClearUser(void); diff --git a/Kernel/threads.c b/Kernel/threads.c index c0c61329..f84ca7c2 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -667,9 +667,10 @@ void Threads_Kill(tThread *Thread, int Status) SHORTREL( &Thread->IsLocked ); // TODO: We may not actually be released... // And, reschedule - if(isCurThread) { + if(isCurThread) + { for( ;; ) - HALT(); + Proc_Reschedule(); } } @@ -678,10 +679,7 @@ void Threads_Kill(tThread *Thread, int Status) */ void Threads_Yield(void) { - tThread *thread = Proc_GetCurThread(); - thread->Remaining = 0; - //while(thread->Remaining == 0) - HALT(); + Proc_Reschedule(); } /** @@ -717,8 +715,9 @@ void Threads_Sleep(void) // Release Spinlock SHORTREL( &glThreadListLock ); - - while(cur->Status != THREAD_STAT_ACTIVE) HALT(); + + while(cur->Status != THREAD_STAT_ACTIVE) + Proc_Reschedule(); } @@ -1141,7 +1140,6 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last) if( gaThreads_NoTaskSwitch[CPU] ) return Last; - // Lock thread list SHORTLOCK( &glThreadListLock ); @@ -1343,6 +1341,7 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last) // Make the new thread non-schedulable thread->CurCPU = CPU; + thread->Remaining = thread->Quantum; SHORTREL( &glThreadListLock );