Moved adding a task to the active list to threads.c
authorJohn Hodge <[email protected]>
Sun, 27 Sep 2009 05:44:57 +0000 (13:44 +0800)
committerJohn Hodge <[email protected]>
Sun, 27 Sep 2009 05:44:57 +0000 (13:44 +0800)
Kernel/arch/x86/proc.c
Kernel/include/threads.h
Kernel/threads.c

index fd91643..76e96c9 100644 (file)
@@ -309,12 +309,7 @@ int Proc_Clone(Uint *Err, Uint Flags)
        newThread->SavedState.EIP = eip;
        
        // Lock list and add to active
-       LOCK( &giThreadListLock );
-       newThread->Next = gActiveThreads;
-       gActiveThreads = newThread;
-       giNumActiveThreads ++;
-       giTotalTickets += newThread->NumTickets;
-       RELEASE( &giThreadListLock );
+       Threads_AddActive(newThread);
        
        Threads_Dump();
        
index 644d033..377b6ac 100644 (file)
@@ -62,5 +62,6 @@ enum {
 extern tThread *Proc_GetCurThread();
 extern tThread *Threads_GetThread(Uint TID);
 extern void    Threads_Wake(tThread *Thread);
+extern void    Threads_AddActive(tThread *Thread);
 
 #endif
index bb0ec73..774507f 100644 (file)
@@ -30,6 +30,7 @@ void  Threads_Kill(tThread *Thread, int Status);
 void   Threads_Yield();
 void   Threads_Sleep();
 void   Threads_Wake(tThread *Thread);
+void   Threads_AddActive(tThread *Thread);
  int   Threads_GetPID();
  int   Threads_GetTID();
  int   Threads_GetUID();
@@ -426,6 +427,22 @@ void Threads_Wake(tThread *Thread)
        }
 }
 
+/**
+ * \fn void Threads_AddActive(tThread *Thread)
+ * \brief Adds a thread to the active queue
+ */
+void Threads_AddActive(tThread *Thread)
+{
+       LOCK( &giThreadListLock );
+       Thread->Next = gActiveThreads;
+       gActiveThreads = Thread;
+       giNumActiveThreads ++;
+       giTotalTickets += Thread->NumTickets;
+       Log("Threads_AddActive: giNumActiveThreads = %i, giTotalTickets = %i",
+               giNumActiveThreads, giTotalTickets);
+       RELEASE( &giThreadListLock );
+}
+
 #if 0
 /**
  * \fn void Threads_SetSignalHandler(int Num, void *Handler)

UCC git Repository :: git.ucc.asn.au