Skip to content

Commit

Permalink
test: Relocate posix mqueue receive buffer
Browse files Browse the repository at this point in the history
For platforms that select Kconfig option CONFIG_KERNEL_COHERENCE,
the receive buffer used in mq_timedreceive() must not be on the
stack. This is because the k_msgq that underlies the POSIX mqueue
will attempt to perform a direct to buffer copy from the sender
when there is a waiting reader.

Fixes zephyrproject-rtos#60796

Signed-off-by: Peter Mitsis <[email protected]>
  • Loading branch information
peter-mitsis authored and carlescufi committed Jul 31, 2023
1 parent 0ae1e37 commit 38352ae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/posix/common/src/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@
K_THREAD_STACK_ARRAY_DEFINE(stacks, N_THR, STACKSZ);

char queue[16] = "server";

char send_data[MESSAGE_SIZE] = "timed data send";

/*
* For platforms that select CONFIG_KERNEL_COHERENCE, the receive buffer can
* not be on the stack as the k_msgq that underlies the mq_timedsend() will
* copy directly to the receiver's buffer when there is already a waiting
* receiver.
*/

char rec_data[MESSAGE_SIZE];

void *sender_thread(void *p1)
{
mqd_t mqd;
Expand All @@ -44,7 +54,6 @@ void *sender_thread(void *p1)
void *receiver_thread(void *p1)
{
mqd_t mqd;
char rec_data[MESSAGE_SIZE];
struct timespec curtime;

mqd = mq_open(queue, O_RDONLY);
Expand Down

0 comments on commit 38352ae

Please sign in to comment.