MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / rt_sem_create

Function rt_sem_create

src/ipc.c:467–484  ·  view source on GitHub ↗

* @brief Creating a semaphore object. * * @note For the semaphore object, its memory space is allocated automatically. * By contrast, the rt_sem_init() function will initialize a static semaphore object. * * @see rt_sem_init() * * @param name is a pointer to the name you would like to give the semaphore. * * @param value is the initial value for the semaphore.

Source from the content-addressed store, hash-verified

465 * @warning This function can NOT be called in interrupt context. You can use macor RT_DEBUG_NOT_IN_INTERRUPT to check it.
466 */
467rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
468{
469 rt_sem_t sem;
470
471 RT_ASSERT(value < 0x10000U);
472 RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
473
474 RT_DEBUG_NOT_IN_INTERRUPT;
475
476 /* allocate object */
477 sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name);
478 if (sem == RT_NULL)
479 return sem;
480
481 _sem_object_init(sem, value, flag, RT_SEM_VALUE_MAX);
482
483 return sem;
484}
485RTM_EXPORT(rt_sem_create);
486
487

Callers 15

rt_udisk_runFunction · 0.85
sys_sem_createFunction · 0.85
uart_apiFunction · 0.85
uart_apiFunction · 0.85
uart_apiFunction · 0.85
sdio_irq_thread_createFunction · 0.85
sensor_fifoFunction · 0.85
sensor_intFunction · 0.85
sensor_fifoFunction · 0.85
sensor_intFunction · 0.85
usb_osal_sem_createFunction · 0.85
pthread_createFunction · 0.85

Calls 2

rt_object_allocateFunction · 0.85
_sem_object_initFunction · 0.85

Tested by 11

_ic_test_openFunction · 0.68
utest_tc_initFunction · 0.68
test_atomic_addFunction · 0.68