More thread issue fixing, still not working
authorJohn Hodge <[email protected]>
Tue, 7 Sep 2010 01:14:35 +0000 (09:14 +0800)
committerJohn Hodge <[email protected]>
Tue, 7 Sep 2010 01:14:35 +0000 (09:14 +0800)
Kernel/arch/x86/include/arch.h
Kernel/threads.c

index 0126be3..3ce9130 100644 (file)
@@ -74,6 +74,7 @@ static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock) {
  * \note This type of lock halts interrupts, so ensure that no timing
  * functions are called while it is held. As a matter of fact, spend as
  * little time as possible with this lock held
+ * \note If \a STACKED_LOCKS is set, this type of spinlock can be nested
  */
 static inline void SHORTLOCK(struct sShortSpinlock *Lock) {
         int    v = 1;
index aa550ab..5695955 100644 (file)
@@ -437,6 +437,14 @@ void Threads_Kill(tThread *Thread, int Status)
        // Lock thread (stop us recieving messages)
        SHORTLOCK( &Thread->IsLocked );
        
+       // Clear Message Queue
+       while( Thread->Messages )
+       {
+               msg = Thread->Messages->Next;
+               free( Thread->Messages );
+               Thread->Messages = msg;
+       }
+       
        // Lock thread list
        SHORTLOCK( &glThreadListLock );
        
@@ -449,14 +457,6 @@ void Threads_Kill(tThread *Thread, int Status)
                return;
        }
        
-       // Clear Message Queue
-       while( Thread->Messages )
-       {
-               msg = Thread->Messages->Next;
-               free( Thread->Messages );       // BIG NO-NO
-               Thread->Messages = msg;
-       }
-       
        // Ensure that we are not rescheduled
        Thread->Remaining = 0;  // Clear Remaining Quantum
        Thread->Quantum = 0;    // Clear Quantum to indicate dead thread

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