-
Notifications
You must be signed in to change notification settings - Fork 145
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
sched-rr: A round-robin scheduler for normal thread #129
base: master
Are you sure you want to change the base?
Conversation
This is a round-robin scheduler implement for normal thread (user-thread) create by pager or pthread lib, and using timeslice, we can prevent user-space thread starvation trigger by busy loop. This scheduler only schedling user thread create by ipc "thread start protocal". Default timeslice is 4096 ticks for now. Other trivial change: - Update defconfing for all board - Add sched-rr into Makefile - Add new config in kernel/Kconfig for setting thread timeslice
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.
Make rr as pluggable policy and refactor.
@@ -46,6 +46,7 @@ includes = \ | |||
board/$(BOARD) \ | |||
include \ | |||
include/platform \ | |||
include/sched-rr \ |
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.
Don't name it after sched-rr
. Instead, use include/sched
and manipulate each scheduling policy through dedicated file.
@@ -93,6 +96,7 @@ loader-all-y += $(call objs_from_dir,kernel,loader-kernel) | |||
|
|||
dirs = \ | |||
kernel/lib \ | |||
kernel/sched-rr \ |
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.
Ditto.
@@ -16,6 +16,7 @@ | |||
#include <user-log.h> | |||
#include <ktimer.h> | |||
#include <interrupt.h> | |||
#include <sched-rr/sched_rr.h> |
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.
Ditto. It is not elegant!
#include <types.h> | ||
#include <thread.h> | ||
#include <ktimer.h> | ||
#include <sched-rr/sched_rr.h> |
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.
Ditto.
@@ -12,6 +12,7 @@ | |||
#include <platform/armv7m.h> | |||
#include <fpage_impl.h> | |||
#include <init_hook.h> | |||
#include <sched-rr/sched_rr.h> |
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.
Ditto.
@@ -411,6 +412,9 @@ static tcb_t *thread_select(tcb_t *parent) | |||
if (thr == NULL) | |||
return NULL; | |||
|
|||
if ((thr = rr_select()) != NULL) |
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.
Please make scheduling policy pluggable as Linux kernel does.
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.
Is like insmod/rmmod or config in make config
?
Thanks.
Also, Linux kernel scheduler is pluggable!? Ain't they choose when 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.
OMg is pluggable....since 2004!
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.
I meant pluggable scheduler framework.
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.
If rr_select
returns NULL, thr
will be modified as NULL and unexpected result
will happen in the following code.
@@ -71,6 +71,10 @@ menu "Thread tweaks" | |||
config INTR_THREAD_MAX | |||
int "Maximum of interrupt threads" | |||
default 256 | |||
|
|||
config THREAD_TIME_SLICE | |||
int "Maximum timeslice for threads" |
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.
Improve the descriptions.
This is a round-robin scheduler implement for normal thread (user-thread)
create by pager or pthread lib, and using timeslice, we can prevent user-space
thread starvation trigger by busy loop.
This scheduler only schedling user thread create by ipc "thread start protocal".
Default timeslice is 4096 ticks for now.
Other trivial change: