MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_sem_delete

Function rt_sem_delete

src/ipc.c:506–526  ·  view source on GitHub ↗

* @brief This function will delete a semaphore object and release the memory space. * * @note This function is used to delete a semaphore object which is created by the rt_sem_create() function. * By contrast, the rt_sem_detach() function will detach a static semaphore object. * When the semaphore is successfully deleted, it will resume all suspended threads in the s

Source from the content-addressed store, hash-verified

504 * ONLY USE the rt_sem_detach() function to complete the detachment.
505 */
506rt_err_t rt_sem_delete(rt_sem_t sem)
507{
508 rt_ubase_t level;
509
510 /* parameter check */
511 RT_ASSERT(sem != RT_NULL);
512 RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);
513 RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE);
514
515 RT_DEBUG_NOT_IN_INTERRUPT;
516
517 level = rt_spin_lock_irqsave(&(sem->spinlock));
518 /* wakeup all suspended threads */
519 rt_susp_list_resume_all(&(sem->parent.suspend_thread), RT_ERROR);
520 rt_spin_unlock_irqrestore(&(sem->spinlock), level);
521
522 /* delete semaphore object */
523 rt_object_delete(&(sem->parent.parent));
524
525 return RT_EOK;
526}
527RTM_EXPORT(rt_sem_delete);
528#endif /* RT_USING_HEAP */
529

Callers 15

rt_udisk_stopFunction · 0.85
_object_node_deleteFunction · 0.85
sys_sem_createFunction · 0.85
uart_apiFunction · 0.85
uart_apiFunction · 0.85
uart_apiFunction · 0.85
sdio_irq_thread_deleteFunction · 0.85
usb_osal_sem_deleteFunction · 0.85
dlmodule_destroyFunction · 0.85
_pthread_data_destroyFunction · 0.85
pthread_detachFunction · 0.85
posix_sem_deleteFunction · 0.85

Calls 6

rt_object_get_typeFunction · 0.85
rt_susp_list_resume_allFunction · 0.85
rt_object_deleteFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.70