Skip to content

Commit

Permalink
Fix sched init for different scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
mlouielu committed Aug 25, 2017
1 parent e26187a commit 430a3bd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/kernel/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ struct thread_info;
#define SCHED_OPT_TICK 3

struct sched {
int (*init)(void);
int (*init)(struct thread_info *thread);
int (*enqueue)(struct thread_info *thread);
int (*dequeue)(struct thread_info *thread);
int (*elect)(int switch_type);
};

int sched_select(int sched_type);
int sched_select(int sched_type, struct thread_info *thread);
int sched_enqueue(struct thread_info *thread);
int sched_dequeue(struct thread_info *thread);
int sched_elect(int flags);
Expand Down
6 changes: 3 additions & 3 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ struct thread_info *start_kernel(void)
show_page_bitmap(); // init_pages();
kmem_cache_init();

/* select a scheduling policy */
sched_select(SCHED_CLASS);

/* idle_thread is not added to the runqueue */
task_init(&idle_task);
thread_idle =
Expand All @@ -161,6 +158,9 @@ struct thread_info *start_kernel(void)
printk("Created main_thread at <%p> with priority=%d\n", thread_main,
thread_main->ti_priority);

/* select a scheduling policy */
sched_select(SCHED_CLASS, thread_main);

/* Reclaim the early-stack physical memory. In the current context, no
* page allocation after this point are allowed. */
printk("Reclaim early stack's physical memory (%d Bytes, order=%d).\n",
Expand Down
4 changes: 2 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern const struct sched sched_bitmap;

static const struct sched *sched;

int sched_select(int sched_type)
int sched_select(int sched_type, struct thread_info *thread)
{
switch (sched_type) {
case SCHED_CLASS_RR:
Expand All @@ -19,7 +19,7 @@ int sched_select(int sched_type)
return -1;
}

return sched->init();
return sched->init(thread);
}

int sched_enqueue(struct thread_info *thread)
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static struct {
.expire = &_expire,
};

static int sched_bitmap_init(void)
static int sched_bitmap_init(__unused struct thread_info *thread)
{
INIT_BITMAP(sched_struct.active);
INIT_BITMAP(sched_struct.expire);
Expand Down
3 changes: 2 additions & 1 deletion kernel/sched/rr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
static LIST_HEAD(rr_runq);
extern struct thread_info *thread_idle;

int sched_rr_init(void)
int sched_rr_init(struct thread_info *thread)
{
sched_rr_enqueue(thread);
return 0;
}

Expand Down

0 comments on commit 430a3bd

Please sign in to comment.