STATUS semDestroy(SEM_ID semId, BOOL dealloc) { int level; level = intLock(); if(!IS_CLASS(semId, semClassId)) { return (ERROR); } objCoreTerminate(&semId->objCore); kernelState = TRUE; intUnlock(level); kernelSemDelete(semId); TASK_SAFE(); kernelExit(); if(dealloc) { objFree(semClassId, (char*)semId); } TASK_UNSAFE(); return (OK); }
static STATUS msgQDestroy(MSG_Q_ID msgQId, BOOL dealloc) { Q_JOB_NODE* pNode; FAST int timeout; FAST int nMsgs; /* TODO isr not allowed */ TASK_SAFE(); TASK_LOCK(); if(!IS_CLASS(msgQId, msgQClassId)) { TASK_UNLOCK(); TASK_UNSAFE(); return (ERROR); } objCoreTerminate(&msgQId->objCore); TASK_UNLOCK(); timeout = NO_WAIT; nMsgs = 0; while(nMsgs < msgQId->maxMsgs) { while(((pNode = qJobGet(msgQId, &msgQId->freeQ, timeout)) != NULL) && (pNode != (Q_JOB_NODE*)NONE)) { nMsgs++; } while(((pNode = qJobGet(msgQId, &msgQId->msgQ, timeout)) != NULL) && (pNode != (Q_JOB_NODE*)NONE)) { nMsgs++; } timeout = 1; } kernelState = TRUE; qJobTerminate(&msgQId->msgQ); qJobTerminate(&msgQId->freeQ); kernelExit(); if(dealloc) { objFree(msgQClassId, (char*)msgQId); } TASK_UNSAFE(); return (OK); }
STATUS wdDestroy ( WDOG_ID wdId, /* ID of watchdog to terminate */ BOOL dealloc /* dealloc associated memory */ ) { int level; if (INT_RESTRICT () != OK) /* restrict isr use */ return (ERROR); level = intLock (); /* LOCK INTERRUPTS */ if (OBJ_VERIFY (wdId, wdClassId) != OK) /* validate watchdog ID */ { intUnlock (level); /* UNLOCK INTERRUPTS */ return (ERROR); } #ifdef WV_INSTRUMENTATION /* windview - level 1 event logging */ EVT_OBJ_1 (OBJ, wdId, wdClassId, EVENT_WDDELETE, wdId); #endif objCoreTerminate (&wdId->objCore); /* invalidate watchdog */ kernelState = TRUE; /* KERNEL ENTER */ intUnlock (level); /* UNLOCK INTERRUPTS */ windWdCancel (wdId); /* cancel watchdog */ wdId->status = WDOG_DEAD; /* dead dog */ TASK_SAFE (); /* TASK SAFE */ windExit (); /* EXIT KERNEL */ if (dealloc) objFree (wdClassId, (char *) wdId); /* deallocate watchdog */ TASK_UNSAFE (); /* TASK UNSAFE */ return (OK); }