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

Function rt_mb_create

src/ipc.c:2453–2491  ·  view source on GitHub ↗

* @brief Creating a mailbox object. * * @note For the mailbox object, its memory space is allocated automatically. * By contrast, the rt_mb_init() function will initialize a static mailbox object. * * @see rt_mb_init() * * @param name is a pointer that given to the mailbox. * * @param size is the maximum number of mails in the mailbox. * For example, when mail

Source from the content-addressed store, hash-verified

2451 * @warning This function can ONLY be called from threads.
2452 */
2453rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
2454{
2455 rt_mailbox_t mb;
2456
2457 RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
2458
2459 RT_DEBUG_NOT_IN_INTERRUPT;
2460
2461 /* allocate object */
2462 mb = (rt_mailbox_t)rt_object_allocate(RT_Object_Class_MailBox, name);
2463 if (mb == RT_NULL)
2464 return mb;
2465
2466 /* set parent */
2467 mb->parent.parent.flag = flag;
2468
2469 /* initialize ipc object */
2470 _ipc_object_init(&(mb->parent));
2471
2472 /* initialize mailbox */
2473 mb->size = (rt_uint16_t)size;
2474 mb->msg_pool = (rt_ubase_t *)RT_KERNEL_MALLOC(mb->size * sizeof(rt_ubase_t));
2475 if (mb->msg_pool == RT_NULL)
2476 {
2477 /* delete mailbox object */
2478 rt_object_delete(&(mb->parent.parent));
2479
2480 return RT_NULL;
2481 }
2482 mb->entry = 0;
2483 mb->in_offset = 0;
2484 mb->out_offset = 0;
2485
2486 /* initialize an additional list of sender suspend thread */
2487 rt_list_init(&(mb->suspend_sender_thread));
2488 rt_spin_lock_init(&(mb->spinlock));
2489
2490 return mb;
2491}
2492RTM_EXPORT(rt_mb_create);
2493
2494

Callers 10

sys_mb_createFunction · 0.85
sys_mbox_newFunction · 0.85
test_gpio_intFunction · 0.85
hal_mailbox_createFunction · 0.85
rt_hw_ifx_eth_initFunction · 0.85
pcap_netif_initFunction · 0.85
test_mailbox_createFunction · 0.85
test_mailbox_deleteFunction · 0.85
rt_perf_thread_mboxFunction · 0.85

Calls 5

rt_object_allocateFunction · 0.85
_ipc_object_initFunction · 0.85
rt_object_deleteFunction · 0.85
rt_list_initFunction · 0.85
rt_spin_lock_initFunction · 0.70

Tested by 4

test_gpio_intFunction · 0.68
test_mailbox_createFunction · 0.68
test_mailbox_deleteFunction · 0.68