From: John Hodge Date: Mon, 23 Jan 2012 00:53:41 +0000 (+0800) Subject: Kernel - Added events to build X-Git-Tag: rel0.15~792^2~21 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=61148f26a5655615567d87c5d139c370a9cdac54;p=tpg%2Facess2.git Kernel - Added events to build --- diff --git a/Kernel/Makefile b/Kernel/Makefile index c0360389..d0c8dbf6 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -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 diff --git a/Kernel/events.c b/Kernel/events.c index 57ad6842..76886e18 100644 --- a/Kernel/events.c +++ b/Kernel/events.c @@ -10,29 +10,28 @@ #include // === 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 index 00000000..5ef4681e --- /dev/null +++ b/Kernel/include/events.h @@ -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 +