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

Function rt_sem_init

src/ipc.c:376–391  ·  view source on GitHub ↗

* @brief This function will initialize a static semaphore object. * * @note For the static semaphore object, its memory space is allocated by the compiler during compiling, * and shall placed on the read-write data segment or on the uninitialized data segment. * By contrast, the rt_sem_create() function will allocate memory space automatically and initialize *

Source from the content-addressed store, hash-verified

374 * @warning This function can ONLY be called from threads.
375 */
376rt_err_t rt_sem_init(rt_sem_t sem,
377 const char *name,
378 rt_uint32_t value,
379 rt_uint8_t flag)
380{
381 RT_ASSERT(sem != RT_NULL);
382 RT_ASSERT(value < 0x10000U);
383 RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
384
385 /* initialize object */
386 rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
387
388 _sem_object_init(sem, value, flag, RT_SEM_VALUE_MAX);
389
390 return RT_EOK;
391}
392RTM_EXPORT(rt_sem_init);
393
394

Callers 15

finsh_system_initFunction · 0.85
critical_initFunction · 0.85
rt_can_openFunction · 0.85
mmcsd_host_initFunction · 0.85
blk.cFile · 0.85
rt_cputimer_initFunction · 0.85
rt_workqueue_createFunction · 0.85
utest_tc_initFunction · 0.85
utest_tc_initFunction · 0.85
utest_tc_initFunction · 0.85

Calls 2

rt_object_initFunction · 0.85
_sem_object_initFunction · 0.85

Tested by 15

uart_taskFunction · 0.68
uart_taskFunction · 0.68
uart_taskFunction · 0.68
can_testFunction · 0.68
uart_sample_v1Function · 0.68
can_sampleFunction · 0.68
uart_sample_v2Function · 0.68
can_sampleFunction · 0.68