X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fevents.c;h=84a1b0a5f3c9a859b70939806744f8e28d0605b7;hb=950126c76c539e76574f6349b833f41c70ed6573;hp=a9eab7865e86244ded7a8cf9dd08bbcf529e7678;hpb=51ab5f489bc356940c95cc936fd0508e8f07ea97;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/events.c b/KernelLand/Kernel/events.c index a9eab786..84a1b0a5 100644 --- a/KernelLand/Kernel/events.c +++ b/KernelLand/Kernel/events.c @@ -26,21 +26,39 @@ void Threads_PostEvent(tThread *Thread, Uint32 EventMask) LOG("Thread->EventState = 0x%x", Thread->EventState); // Currently sleeping on an event? - if( Thread->Status == THREAD_STAT_EVENTSLEEP ) + switch(Thread->Status) { - // Waiting on this event? + // Waiting on this event? + case THREAD_STAT_EVENTSLEEP: if( (Uint32)Thread->RetStatus & EventMask ) { // Wake up LOG("Waking thread %p(%i %s)", Thread, Thread->TID, Thread->ThreadName); Threads_AddActive(Thread); } + break; + case THREAD_STAT_SEMAPHORESLEEP: + if( EventMask & THREAD_EVENT_TIMER ) + { + LOG("Waking %p(%i %s) from semaphore on timer", + Thread, Thread->TID, Thread->ThreadName); + Semaphore_ForceWake(Thread); + } + break; } SHORTREL( &Thread->IsLocked ); LEAVE('-'); } +/** + * \brief Clear an event without waiting + */ +void Threads_ClearEvent(Uint32 EventMask) +{ + Proc_GetCurThread()->EventState &= ~EventMask; +} + /** * \brief Wait for an event to occur */ @@ -73,7 +91,7 @@ Uint32 Threads_WaitEvents(Uint32 EventMask) // Note stored anywhere because we're woken using other means SHORTREL( &glThreadListLock ); SHORTREL( &us->IsLocked ); - while(us->Status == THREAD_STAT_EVENTSLEEP) Threads_Yield(); + Threads_int_WaitForStatusEnd(THREAD_STAT_EVENTSLEEP); // Woken when lock is acquired SHORTLOCK( &us->IsLocked ); }