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

Function sys_mq_timedsend

components/lwp/lwp_syscall.c:9176–9202  ·  view source on GitHub ↗

* @brief Send a message to a message queue with a timeout. * * This function sends a message to the specified message queue, but it allows the sender * to specify a timeout. If the message queue is full, the function will block until either * space becomes available or the specified timeout expires. If the timeout expires without * space being available, the function returns an error. * * @

Source from the content-addressed store, hash-verified

9174 * @see sys_mq_send
9175 */
9176sysret_t sys_mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at)
9177{
9178 int ret = 0;
9179#ifdef ARCH_MM_MMU
9180 char *kmsg = RT_NULL;
9181 struct timespec at_k;
9182
9183 kmsg = (char *)kmem_get(len + 1);
9184 if (!kmsg)
9185 return -ENOMEM;
9186
9187 lwp_get_from_user(&at_k, (void *)at, sizeof(struct timespec));
9188 lwp_get_from_user(kmsg, (void *)msg, len + 1);
9189 ret = mq_timedsend(mqd, kmsg, len, prio, &at_k);
9190 if (ret < 0)
9191 {
9192 ret = GET_ERRNO();
9193 }
9194
9195 kmem_put(kmsg);
9196
9197 return ret;
9198#else
9199 ret = mq_timedsend(mqd, msg, len, prio, at);
9200 return (ret < 0 ? GET_ERRNO() : ret);
9201#endif
9202}
9203
9204/**
9205 * @brief Receive a message from a message queue with a timeout.

Callers

nothing calls this directly

Calls 4

kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
mq_timedsendFunction · 0.85
kmem_putFunction · 0.85

Tested by

no test coverage detected