From e65509a58eea37f504654a6fba1e11dd69026ebe Mon Sep 17 00:00:00 2001 From: zhkag Date: Mon, 26 Jun 2023 12:06:06 +0800 Subject: [src][components][include]消息队列支持优先级 (#7382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/posix/ipc/Kconfig | 1 + components/libc/posix/ipc/mqueue.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'components') 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 " 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); -- cgit v1.3.1