From 2a859c78cdd0716c6453076005c3ce949b2c8b25 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 8 Jul 2014 18:00:54 +0200 Subject: [PATCH] SQUASHME: do it right --- core/msg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/msg.c b/core/msg.c index 3492f24a1c..3d50fb1b34 100644 --- a/core/msg.c +++ b/core/msg.c @@ -58,8 +58,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) return msg_send_int(m, target_pid); } - m->sender_pid = sched_active_pid; - if (m->sender_pid == target_pid) { + if ((unsigned int)sched_active_pid == target_pid) { return msg_send_to_self(m); } @@ -67,6 +66,8 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) tcb_t *target = (tcb_t*) sched_threads[target_pid]; + m->sender_pid = sched_active_pid; + if (target == NULL) { DEBUG("msg_send(): target thread does not exist\n"); eINT(); @@ -134,6 +135,7 @@ int msg_send_to_self(msg_t *m) { unsigned int state = disableIRQ(); + m->sender_pid = sched_active_pid; int res = queue_msg((tcb_t *) sched_active_thread, m); restoreIRQ(state);