summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorzhkag <[email protected]>2023-06-26 12:06:06 +0800
committerGitHub <[email protected]>2023-06-26 00:06:06 -0400
commite65509a58eea37f504654a6fba1e11dd69026ebe (patch)
treea6a101d0f25e38f4613534cec4629c2b10b7d18f /components
parent64c1d626e2ccfe150cc4f9136c2f952dd2ff64f0 (diff)
[src][components][include]消息队列支持优先级 (#7382)
Diffstat (limited to 'components')
-rw-r--r--components/libc/posix/ipc/Kconfig1
-rw-r--r--components/libc/posix/ipc/mqueue.c7
2 files changed, 5 insertions, 3 deletions
diff --git a/components/libc/posix/ipc/Kconfig b/components/libc/posix/ipc/Kconfig
index a1e4fc1632..cf3135e53a 100644
--- a/components/libc/posix/ipc/Kconfig
+++ b/components/libc/posix/ipc/Kconfig
@@ -24,6 +24,7 @@ config RT_USING_POSIX_PIPE_SIZE
config RT_USING_POSIX_MESSAGE_QUEUE
bool "Enable posix message queue <mqueue.h>"
select RT_USING_POSIX_CLOCK
+ select RT_USING_MESSAGEQUEUE_PRIORITY
default n
config RT_USING_POSIX_MESSAGE_SEMAPHORE
diff --git a/components/libc/posix/ipc/mqueue.c b/components/libc/posix/ipc/mqueue.c
index 22d2854770..49ce6bf98d 100644
--- a/components/libc/posix/ipc/mqueue.c
+++ b/components/libc/posix/ipc/mqueue.c
@@ -232,7 +232,7 @@ ssize_t mq_receive(mqd_t id, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
return -1;
}
- result = rt_mq_recv(mqdes->mq, msg_ptr, msg_len, RT_WAITING_FOREVER);
+ result = rt_mq_recv_prio(mqdes->mq, msg_ptr, msg_len, (rt_int32_t *)msg_prio, RT_WAITING_FOREVER, RT_UNINTERRUPTIBLE);
if (result >= 0)
return rt_strlen(msg_ptr);
@@ -255,7 +255,7 @@ int mq_send(mqd_t id, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
return -1;
}
- result = rt_mq_send(mqdes->mq, (void*)msg_ptr, msg_len);
+ result = rt_mq_send_wait_prio(mqdes->mq, (void *)msg_ptr, msg_len, msg_prio, 0, RT_UNINTERRUPTIBLE);
if (result == RT_EOK)
return 0;
@@ -287,7 +287,8 @@ ssize_t mq_timedreceive(mqd_t id,
if (abs_timeout != RT_NULL)
tick = rt_timespec_to_tick(abs_timeout);
- result = rt_mq_recv(mqdes->mq, msg_ptr, msg_len, tick);
+ result = rt_mq_recv_prio(mqdes->mq, msg_ptr, msg_len, (rt_int32_t *)msg_prio, tick, RT_UNINTERRUPTIBLE);
+
if (result >= 0)
return rt_strlen(msg_ptr);