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

Function sys_mq_create

components/lwp/lwp_syscall.c:2590–2628  ·  view source on GitHub ↗

* @brief Creates a message queue. * * This system call creates a new message queue with a specified name, message size, * maximum number of messages, and associated flags. The message queue allows * messages of a given size to be sent and received between tasks or threads. * * @param[in] name The name of the message queue. It should be a unique * identifier and a

Source from the content-addressed store, hash-verified

2588 * `max_msgs` may lead to resource exhaustion.
2589 */
2590rt_mq_t sys_mq_create(const char *name,
2591 rt_size_t msg_size,
2592 rt_size_t max_msgs,
2593 rt_uint8_t flag)
2594{
2595 rt_mq_t mq = RT_NULL;
2596
2597 int len = 0;
2598 char *kname = RT_NULL;
2599
2600 len = lwp_user_strlen(name);
2601 if (len <= 0)
2602 {
2603 return RT_NULL;
2604 }
2605
2606 kname = (char *)kmem_get(len + 1);
2607 if (!kname)
2608 {
2609 return RT_NULL;
2610 }
2611
2612 if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1))
2613 {
2614 kmem_put(kname);
2615 return RT_NULL;
2616 }
2617
2618 mq = rt_mq_create(kname, msg_size, max_msgs, flag);
2619 if (lwp_user_object_add(lwp_self(), (rt_object_t)mq) != 0)
2620 {
2621 rt_mq_delete(mq);
2622 mq = NULL;
2623 }
2624
2625 kmem_put(kname);
2626
2627 return mq;
2628}
2629
2630/**
2631 * @brief Deletes a message queue.

Callers

nothing calls this directly

Calls 8

lwp_user_strlenFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_mq_createFunction · 0.85
lwp_user_object_addFunction · 0.85
lwp_selfFunction · 0.85
rt_mq_deleteFunction · 0.85

Tested by

no test coverage detected