-
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
sys/sched_rr: Add a round robin scheduler module #16126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems there are a couple of unrelated commits..
@kfessel the commit history seems a bit weird, the example is introduced before the functionality. |
the example before the feature can run without the feature and, since there is no round robin scheduling, not work. (at first i thought i go with one big commit and added the example first but than i saw the gitignore thing and went with mutiple commits) |
i squashed the fixups into three |
sorry for the huge number of fixups i did fix for the static tests but since i read the results while they where not finished complaining and in the next run they found new issues I hope there are no static complains left (back to 5 fixups :( ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments inline. Looks pretty good to me.
Would you mind to replace the evil_schedule_hack_dont_do_this_at_home()
function in tests/malloc_thread_safety/main.c
in an additional commit? (I could also do this as follow up, if I don't forget.)
I believe uncrustify is on a hunt for my coding style |
It's only checking core/ and very few other modules. So touching anything there will probably make it complain, given that the version used in riotdocker is outdated and disagrees with its newer incarnation. |
rebased for the new uncrustify config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some more comments inline
tests/sys_sched_round_robin/main.c
Outdated
|
||
static kernel_pid_t main_pid; | ||
|
||
void * thread_wakeup_main(void * d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs uncrustifying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kfessel missing uncrustify :)
examples/thread_duel/README.md
Outdated
Thread-Duel | ||
============ | ||
|
||
This is a thread duel application to show RIOTs multi-threading abilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline @kaspar030 mentioned this should say it's a show-case of round-robin, and not RIOTs multi-threading since most use cases just follow a priority scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments inline
@fjmolinas shall i squash? |
206de1b
to
c9debf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpicks otherwise this one is fine for me, @maribu is all good on your side?
tests/sys_sched_round_robin/main.c
Outdated
|
||
static kernel_pid_t main_pid; | ||
|
||
void * thread_wakeup_main(void * d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kfessel missing uncrustify :)
c9debf0
to
528906f
Compare
Code-wise, this looks good to me. Please squash! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK from my side.
Some BOARDs need to be added to insufficient memory list, and test is not passing on native |
shall I squash the two fixups? |
to avoid priority-inversion screwing up the test
2d21a76
to
2594032
Compare
I would like to use RIOT with multiple threads at the same priority,
that might not cooperate but should share CPU time. see #14810
Preconditions that influenced how this PR is written:
sys is not allowed to access core structures see #14810
core is not allowed to rely sys/xtimer see #15069
a core/timer is unlikely to come #15080
Contribution description
This:
implements the timing part in a module in sys and
adds an interface to core that provides information about the runqueues and the core round robin functionality.
adds an thread duel example with multiple implementations for concurrent thread
How it works
This round robin scheduler, round robins the active priorities runqueue -that was what #14810 did- , if there is more than one thread.
It uses extra information to activate or inactivate -this was added with #15069-:
(This implies: it may hold on a 1 thread runqueue and do a round robin, while this is an unnessecary call to the scheduler, that one is quiet effective in handling it (comparable to: yield_higher))
This is done to only have timer active if it is needed and to avoid stopping or restarting the timer which is processing the list of timers (O(n) with n = the number of active timers). While the example and test use only one timer -> O(n) for n=1 is quiet fast. real applications might have many more timers thus increase n.
Testing procedure
create multiple threads of same priority that should work in parallel
without this module only one of them will run.
or
use the example provided
enable and disable the round robin module and see how the threads work or not work in "parallel"
or
use the provided test sys_sched_round_robin which should run to [SUCESS] with sched_round_robin
(the main function locks itself by a mutex wich is relesed by a thread than runs parallel to an other thread)
the test can be tested by removing sched_round_robin from its USEMODULE than there will be no [SUCESS]
Issues/PRs references
#14810 #15069 #15080
@maribu @benpicco @fjmolinas might want to have a look at this