[riot-devel] Question about RIOT/tests/thread_msg
attilio.dona at gmail.com
Wed Apr 6 13:32:39 CEST 2016
thread_msg does a context switch between p3 and p1 because p1 does not have
a message queue.
The second message from p3 causes p3 to go into a blocked state and give up
control otherwise the previous message will be lost.
if in p1 a msg_queue is defined:
void *thread1(void *arg)
puts("THREAD 1 start\n");
then thread_msg example will run as documented until the message queue is
I hope this little explanation may help ...
On Thu, Mar 31, 2016 at 10:35 AM, OuyangJianwen <jianwen.ouyang at outlook.com>
> I am a new beginner to learn RIOT. I got some question when I run the
> "thread_msg" on board "SAMR21-xpro".
> For the thread1, thread2 and thread3, they have the same priority. so when
> the thread3 is running, how can scheduler switch to the thread1.
> I saw these in the API:
> "In case of equal priorities, the threads are scheduled in a
> semi-cooperative fashion. That means that unless an interrupt happens,
> threads with the same priority will only switch due to voluntary or
> implicit context switches."
> "Some functions that unblock another thread, e.g. msg_send()
> or mutex_unlock()
> can cause a thread switch, if the target had a higher priority."
> but here, all the three threads have the same priority, so according the
> rule, even there is msg_send()
> the thread3 should not be blocked and run forever, but it doesn't.
> Thanks for your time!
> Jianwen OUYANG
> devel mailing list
> devel at riot-os.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the devel