Kernel - Added events to build
authorJohn Hodge <[email protected]>
Mon, 23 Jan 2012 00:53:41 +0000 (08:53 +0800)
committerJohn Hodge <[email protected]>
Mon, 23 Jan 2012 00:53:41 +0000 (08:53 +0800)
Kernel/Makefile
Kernel/events.c
Kernel/include/events.h [new file with mode: 0644]

index c036038..d0c8dbf 100644 (file)
@@ -53,7 +53,7 @@ BUILDINFO_SRC := $(OBJDIR)buildinfo.c$(OBJSUFFIX)
 OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
 OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o
 OBJ += messages.o modules.o syscalls.o system.o
-OBJ += threads.o mutex.o semaphore.o workqueue.o
+OBJ += threads.o mutex.o semaphore.o workqueue.o events.o
 OBJ += drv/proc.o drv/fifo.o drv/iocache.o drv/pci.o
 OBJ += drv/vterm.o drv/vterm_font.o drv/vterm_vt100.o drv/vterm_output.o drv/vterm_input.o drv/vterm_termbuf.o
 OBJ += binary.o bin/elf.o bin/pe.o
index 57ad684..76886e1 100644 (file)
 #include <events.h>
 
 // === CODE ===
-void Threads_PostEvent(tThread *Thread, int EventID)
+void Threads_PostEvent(tThread *Thread, Uint32 EventMask)
 {
-       if( EventID < 0 || EventID > N_EVENTS )
-       {
-               return ;
-       }
+       // TODO: Check that only one bit is set?
+       if( EventMask == 0 )    return ;
        
-       SHORTLOCK( Thread->IsLocked );
+       SHORTLOCK( &Thread->IsLocked );
 
-       Thread->EventState |= 1 << EventID;
+       Thread->EventState |= EventMask;
        
        // Currently sleeping on an event?
-       if( Thread->State == THREAD_STAT_EVENTSLEEP )
+       if( Thread->Status == THREAD_STAT_EVENTSLEEP )
        {
                // Waiting on this event?
-               if( (Uint32)Thread->RetStatus & (1 << EventID) )
+               if( (Uint32)Thread->RetStatus & EventMask )
                {
                        // Wake up
+                       // TODO: Does it matter if the thread is locked here?
                        Threads_AddActive(Thread);
                }
        }
        
-       SHORTREL( Thread->IsLocked );
+       SHORTREL( &Thread->IsLocked );
 }
 
 Uint32 Threads_WaitEvents(Uint32 EventMask)
@@ -66,7 +65,7 @@ Uint32 Threads_WaitEvents(Uint32 EventMask)
        rv = us->EventState & EventMask;
        us->EventState &= ~EventMask;
        
-       SHORTREL( us->IsLocked );
+       SHORTREL( &us->IsLocked );
        
        return rv;
 }
diff --git a/Kernel/include/events.h b/Kernel/include/events.h
new file mode 100644 (file)
index 0000000..5ef4681
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Acess2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * events.h
+ * - Thread Events
+ */
+#ifndef _EVENTS_H_
+#define _EVENTS_H_
+
+#define THREAD_EVENT_VFS       0x00000001
+#define THREAD_EVENT_IPCMSG    0x00000002
+#define THREAD_EVENT_SIGNAL    0x00000004
+
+// === FUNCTIONS ===
+extern void    Threads_PostEvent(tThread *Thread, Uint32 EventMask);
+extern Uint32  Threads_WaitEvents(Uint32 EventMask);
+
+#endif
+

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