From 622d473eb31e4ab5486e2eee1d2e2f6f0f7b4f14 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser <kaspar@schleiser.de> Date: Wed, 12 Feb 2014 19:12:58 +0100 Subject: [PATCH] core: msg: yield after queueing of a message if REPLY_BLOCKED When setting the running task reply_blocked, it is implicitly removed from the runqueue. But if queueing of a msg is actually successful, the thread exits msg_send without yielding, continuing to run even if it's not supposed to. Nice example of why multiple function exit points lead to weird errors... --- core/msg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/msg.c b/core/msg.c index fa8736ae9c..f40d1e7198 100644 --- a/core/msg.c +++ b/core/msg.c @@ -78,6 +78,9 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) if (target->msg_array && queue_msg(target, m)) { DEBUG("msg_send() %s:%i: Target %i has a msg_queue. Queueing message.\n", __FILE__, __LINE__, target_pid); eINT(); + if (active_thread->status == STATUS_REPLY_BLOCKED) { + thread_yield(); + } return 1; } -- GitLab