X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fworkqueue.c;h=f5d78f80511a82401f5a51ea0c5afed9ce59768f;hb=9b107e55699bea78c68d35a6a6591f2c1f6a9cc4;hp=3e35b069ead04355075ee4eb9b0b8953e6ea60a4;hpb=d3c92d9489a096db306e5a028ad65ff95431ba7d;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/workqueue.c b/KernelLand/Kernel/workqueue.c index 3e35b069..f5d78f80 100644 --- a/KernelLand/Kernel/workqueue.c +++ b/KernelLand/Kernel/workqueue.c @@ -16,6 +16,8 @@ void Workqueue_Init(tWorkqueue *Queue, const char *Name, size_t NextOfset) { Queue->Name = Name; Queue->NextOffset = NextOfset; + Queue->Sleeper = NULL; + Queue->SleepTail = NULL; } void *Workqueue_GetWork(tWorkqueue *Queue) @@ -36,7 +38,7 @@ void *Workqueue_GetWork(tWorkqueue *Queue) Threads_int_Sleep(THREAD_STAT_QUEUESLEEP, Queue, 0, - &Queue->Sleeper, NULL, &Queue->Protector); + &Queue->Sleeper, &Queue->SleepTail, &Queue->Protector); } } @@ -53,9 +55,12 @@ void Workqueue_AddWork(tWorkqueue *Queue, void *Ptr) if( Queue->Sleeper ) { - if( Queue->Sleeper->Status != THREAD_STAT_ACTIVE ) - Threads_AddActive(Queue->Sleeper); - Queue->Sleeper = NULL; + ASSERTC( Queue->Sleeper->Status, !=, THREAD_STAT_ACTIVE ); + tThread *next_sleeper = Queue->Sleeper->Next; + Threads_AddActive(Queue->Sleeper); + Queue->Sleeper = next_sleeper; + if(!next_sleeper) + Queue->SleepTail = NULL; } SHORTREL(&Queue->Protector); }