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

Function sys_mb_create

components/lwp/lwp_syscall.c:2322–2356  ·  view source on GitHub ↗

* @brief Creates a mailbox for inter-thread or inter-process communication. * * This system call creates a mailbox object with the specified name and size. * The mailbox is used to exchange messages between threads or tasks in a * synchronized manner. The mailbox can be used to send and receive messages * of a specified size. * * @param[in] name A string representing the name of the mailbox

Source from the content-addressed store, hash-verified

2320 * @see sys_mb_delete(), sys_mb_send(), sys_mb_recv()
2321 */
2322rt_mailbox_t sys_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
2323{
2324 int len = 0;
2325 rt_mailbox_t mb = RT_NULL;
2326 char *kname = RT_NULL;
2327
2328 len = lwp_user_strlen(name);
2329 if (len <= 0)
2330 {
2331 return RT_NULL;
2332 }
2333
2334 kname = (char *)kmem_get(len + 1);
2335 if (!kname)
2336 {
2337 return RT_NULL;
2338 }
2339
2340 if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1))
2341 {
2342 kmem_put(kname);
2343 return RT_NULL;
2344 }
2345
2346 mb = rt_mb_create(kname, size, flag);
2347 if (lwp_user_object_add(lwp_self(), (rt_object_t)mb) != 0)
2348 {
2349 rt_mb_delete(mb);
2350 mb = NULL;
2351 }
2352
2353 kmem_put(kname);
2354
2355 return mb;
2356}
2357
2358/**
2359 * @brief Deletes a mailbox object.

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_mb_createFunction · 0.85
lwp_user_object_addFunction · 0.85
lwp_selfFunction · 0.85
rt_mb_deleteFunction · 0.85

Tested by

no test coverage detected