How to write a C Program to Destroy a semaphore in C Programming Language ?
Solution For C Program :
/**
* Destroys a semaphore.
*
* @param sem is the semaphore to be destroyed.
*/
void
sys_sem_free(sys_sem_t *sem)
{
u32_t i;
/* Find a semaphore that is in use. */
for(i = 0; i < SYS_SEM_MAX; i++) {
if(sems[i].queue == sem->queue) {
break;
}
}
/* Delete Sem , By Jin */
vQueueDelete(sem->queue);
/* Clear the queue handle. */
sem->queue = 0;
/* Clear the queue handle in global array. */
sems[i].queue = 0;
/* Update the semaphore statistics. */
#if SYS_STATS
STATS_DEC(sys.sem.used);
#endif /* SYS_STATS */
}
Learn More :
Example
- C Program String - Alphabet Count Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program Switch - Case Example
- C Program if - else if - else Example
- C Program Friend & Operator: Point2D Example
- C Program Friend & Operator: Vector Example
- C Program Recursion Example
- C Program Structure Example-2
- C Program Structure Example
- C Program Pointer Example
- C Program Function Example
- C Program String Example
- C Program Character Example
- C Program sizeof & memcpy Example
- C Program Array Example
- C Program Side Length Example
- C Program Pipes()
- C Program 0-1000 to Ordinary
- C Program Roboturtle
- C Program to Destroys a Mailbox
- C Code for Testing the pH Meter V1.0
- APA 102c test program
- How To Retarget the C Library printf function to the UART.