Usermode/ld-acess - Disabled PIC (not needed)
[tpg/acess2.git] / Kernel / messages.c
index 4765d65..ce23d6b 100644 (file)
@@ -2,10 +2,15 @@
  * AcessOS Microkernel Version
  * messages.c
  */
+#define DEBUG  1
 #include <acess.h>
 #include <threads.h>
+#include <threads_int.h>
 #include <errno.h>
 
+// === IMPORTS ===
+extern tShortSpinlock  glThreadListLock;
+
 // === CODE ===
 /**
  * \fn int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
@@ -20,18 +25,18 @@ int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
        tThread *thread;
        tMsg    *msg;
        
-       Log("Proc_SendMessage: (Err=%p, Dest=%i, Length=%i, Data=%p)", Err, Dest, Length, Data);
+       ENTER("pErr iDest iLength pData", Err, Dest, Length, Data);
        
        if(Length <= 0 || !Data) {
                *Err = -EINVAL;
-               return -1;
+               LEAVE_RET('i', -1);
        }
        
        // Get thread
        thread = Threads_GetThread( Dest );
        
        // Error check
-       if(!thread) {   return -1;      }
+       if(!thread)     LEAVE_RET('i', -1);
        
        // Get Spinlock
        SHORTLOCK( &thread->IsLocked );
@@ -39,7 +44,7 @@ int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
        // Check if thread is still alive
        if(thread->Status == THREAD_STAT_DEAD) {
                SHORTREL( &thread->IsLocked );
-               return -1;
+               LEAVE_RET('i', -1);
        }
        
        // Create message
@@ -60,9 +65,11 @@ int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
        
        SHORTREL(&thread->IsLocked);
        
+       SHORTLOCK(&glThreadListLock);
        Threads_Wake( thread );
+       SHORTREL(&glThreadListLock);
        
-       return 0;
+       LEAVE_RET('i', 0);
 }
 
 /**

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