Hi, On 11/29/2016 10:27 AM, Oleg Hahm wrote: > I would call it rather a bug in the documentation. The behavior of the > scheduler for threads of the same priority is simply underspecified.
We had that discussion offline. The "bug" is both in Cortex-M's ISR handling and in the docs. > "Assigning the same priority to two or more threads is usually not a good > idea. A thread in RIOT may run until it yields (thread_yield) or another > thread with higher priority is runnable (STATUS_ON_RUNQUEUE) again. Multiple > threads with the same priority will therefore be scheduled cooperatively: when > one of them is running, all others with the same priority depend on it to > yield (or be interrupted by a thread with higher priority). This last half sentence (in braces) is wrong. A higher thread might interrupt one with "siblings" of the same priority, but after the high-prio thread is done, the scheduler would switch back to the initial thread. We should re-word the whole paragraph. > Hence, if we change the scheduler and update the documentation accordingly, we > should also make sure that the pointer in the list of threads with equal > priority is not advanced if a thread gets interrupted by a thread with a > higher priority, either. I.e., the pointer should only be advanced if a thread > explicitly calls `thread_yield()`. That is already the case. thread_yield() advances the current priority's circular list, then calls thread_yield_higher(). But the ISR handling should directly call thread_yield_higher() instead of thread_yield(), as Charles pointed out. Kaspar
signature.asc
Description: OpenPGP digital signature
_______________________________________________ devel mailing list devel@riot-os.org https://lists.riot-os.org/mailman/listinfo/devel