-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: msg_receive should yield #1835
Conversation
The logic in this PR is incorrect. Use this instead: diff --git a/core/msg.c b/core/msg.c
index ec16e94..6a0a83a 100644
--- a/core/msg.c
+++ b/core/msg.c
@@ -310,12 +310,15 @@ static int _msg_receive(msg_t *m, int block)
*m = *sender_msg;
/* remove sender from queue */
+ int16_t other_prio = -1;
if (sender->status != STATUS_REPLY_BLOCKED) {
sender->wait_data = NULL;
sched_set_status(sender, STATUS_PENDING);
+ other_prio = sender->priority;
}
eINT();
+ if (other_prio >= 0) {
+ sched_switch(other_prio);
+ }
return 1;
} The thread will only yield if it's appropriate. |
I wouldn't call it incorrect, but less efficient, yes. I will switch to your proposal if there's a consensus that this change does not have any side effects and is wanted behavior. |
Why is |
That's handled in sched_switch. |
With #1836 you're patch would be mostly superfluous if I replace |
Yes, my PR handles this function. |
I think even with your PR it's less expensive to check the sender priority before hand. If I just call |
ACK |
@kaspar030, do you agree? |
@kaspar030, @LudwigOrtmann, @authmillenon, can I get some of you for a second ACK? |
yep! ACK after squash. |
If a thread sends blocking, but the target thread is not currently in receive mode, the sender gets queued. If it has a higher priority it should run again as soon as the target goes into receiving mode.
8539a02
to
4fd3d62
Compare
Squashed. |
core: msg_receive should yield
If a thread sends blocking, but the target thread is not currently in
receive mode, the sender gets queued. If it has a higher priority it
should run again as soon as the target goes into receiving mode.