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
#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)
rv = us->EventState & EventMask;
us->EventState &= ~EventMask;
- SHORTREL( us->IsLocked );
+ SHORTREL( &us->IsLocked );
return rv;
}
--- /dev/null
+/*
+ * 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
+