TaskSignal sets the calling task status to WAITING to prevent recursion through TaskYield.

This commit is contained in:
Douglas Clowes
2012-11-30 10:35:26 +11:00
parent 1fe4e40e8b
commit ca69d44b3d

3
task.c
View File

@ -304,12 +304,14 @@ int TaskYield(pTaskMan self)
int TaskSignal(pTaskMan self, int iSignal, void *pSigData)
{
pTaskHead pTemp, pEnd;
int myStatus = self->pCurrent->iStatus;
assert(self);
assert(self->iID == TASKERID);
/* Do one cycle until we are at the caller, then return to him */
pEnd = self->pCurrent;
pEnd->iStatus = WAITING;
IncrTaskPointer(self);
while (self->pCurrent != pEnd) {
if (self->pCurrent->pSignal) {
@ -318,6 +320,7 @@ int TaskSignal(pTaskMan self, int iSignal, void *pSigData)
IncrTaskPointer(self);
}
/* finally, tell me about the thingie as well */
pEnd->iStatus = myStatus;
if (pEnd->pSignal) {
pEnd->pSignal(pEnd->pData, iSignal, pSigData);
}