Hi,

Thanks for the observation! It's true that setConsumed should only be called 
once per kernel entry, and it's not obvious just from the code snippets to 
observe that this is true.

However, the semantics of YieldTo mean that both of these code paths cannot be 
executed in the same kernel entry.

If return_now is true, this means that the current thread will be switched to 
and sc->scYieldFrom should be NULL (as the YieldTo call has completed). This is 
usually the case if the calling thread YieldTo a lower priority thread, or a 
thread that is not runnable. On the other hand if return_now is false, the 
YieldTo resulted in the thread being YieldedTo being switched to, so we return 
the result of the YieldTo on a different kernel entry (when we run the thread 
that called YieldTo again).

With this context, take a look at the if block here: 
https://github.com/seL4/seL4/blob/master/src/object/schedcontext.c#L191
Where you can see that we only set sc->scYieldFrom when we also set return_now 
to false.

Glad to see someone looking at the MCS kernel.
Anna.



Confidentiality Note:This email is intended only for the person or entity to 
which it is addressed and may contain information that is privileged, 
confidential or otherwise protected from disclosure. Unauthorized use, 
dissemination, distribution or copying of this email or the information herein 
by anyone other than the intended recipient is strictly prohibited. If you have 
received this email in error, please notify the sender immediately and destroy 
the original message, any attachments thereto and all copies.
_______________________________________________
Devel mailing list
Devel@sel4.systems
https://sel4.systems/lists/listinfo/devel

Reply via email to