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

Function rt_mb_init

src/ipc.c:2346–2376  ·  view source on GitHub ↗

* @brief Initialize a static mailbox object. * * @note For the static mailbox 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_mb_create() function will allocate memory space automatically and initialize the mailbox. * * @see rt_

Source from the content-addressed store, hash-verified

2344 * @warning This function can ONLY be called from threads.
2345 */
2346rt_err_t rt_mb_init(rt_mailbox_t mb,
2347 const char *name,
2348 void *msgpool,
2349 rt_size_t size,
2350 rt_uint8_t flag)
2351{
2352 RT_ASSERT(mb != RT_NULL);
2353 RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
2354
2355 /* initialize object */
2356 rt_object_init(&(mb->parent.parent), RT_Object_Class_MailBox, name);
2357
2358 /* set parent flag */
2359 mb->parent.parent.flag = flag;
2360
2361 /* initialize ipc object */
2362 _ipc_object_init(&(mb->parent));
2363
2364 /* initialize mailbox */
2365 mb->msg_pool = (rt_ubase_t *)msgpool;
2366 mb->size = (rt_uint16_t)size;
2367 mb->entry = 0;
2368 mb->in_offset = 0;
2369 mb->out_offset = 0;
2370
2371 /* initialize an additional list of sender suspend thread */
2372 rt_list_init(&(mb->suspend_sender_thread));
2373 rt_spin_lock_init(&(mb->spinlock));
2374
2375 return RT_EOK;
2376}
2377RTM_EXPORT(rt_mb_init);
2378
2379

Callers 8

rt_hw_wifi_initFunction · 0.85
rt_mmcsd_core_initFunction · 0.85
MailMethod · 0.85
rt_hw_tiva_eth_initFunction · 0.85
test_mailbox_initFunction · 0.85
test_mailbox_deatchFunction · 0.85

Calls 4

rt_object_initFunction · 0.85
_ipc_object_initFunction · 0.85
rt_list_initFunction · 0.85
rt_spin_lock_initFunction · 0.70

Tested by 3

test_mailbox_initFunction · 0.68
test_mailbox_deatchFunction · 0.68