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

Function sys_event_create

components/lwp/lwp_syscall.c:2134–2168  ·  view source on GitHub ↗

* @brief Creates an event object for inter-thread or inter-process communication. * * @param name A string representing the name of the event. If `NULL`, the event will * be created without a name. Named events can be identified and accessed * globally if supported by the system. * @param flag Specifies the behavior of the event. Possible values include: *

Source from the content-addressed store, hash-verified

2132 * @see sys_event_delete(), sys_event_send(), sys_event_recv()
2133 */
2134rt_event_t sys_event_create(const char *name, rt_uint8_t flag)
2135{
2136 int len = 0;
2137 rt_event_t event = RT_NULL;
2138 char *kname = RT_NULL;
2139
2140 len = lwp_user_strlen(name);
2141 if (len <= 0)
2142 {
2143 return RT_NULL;
2144 }
2145
2146 kname = (char *)kmem_get(len + 1);
2147 if (!kname)
2148 {
2149 return RT_NULL;
2150 }
2151
2152 if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1))
2153 {
2154 kmem_put(kname);
2155 return RT_NULL;
2156 }
2157
2158 event = rt_event_create(kname, flag);
2159 if (lwp_user_object_add(lwp_self(), (rt_object_t)event) != 0)
2160 {
2161 rt_event_delete(event);
2162 event = NULL;
2163 }
2164
2165 kmem_put(kname);
2166
2167 return event;
2168}
2169
2170/**
2171 * @brief Deletes a system event 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_event_createFunction · 0.85
lwp_user_object_addFunction · 0.85
lwp_selfFunction · 0.85
rt_event_deleteFunction · 0.85

Tested by

no test coverage detected