Skip to content

Commit 7e298bf

Browse files
committed
Fix sched init for different scheduler
1 parent eabe264 commit 7e298bf

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

include/kernel/sched.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct thread_info;
1818
#define SCHED_OPT_TICK 3
1919

2020
struct sched {
21-
int (*init)(void);
21+
int (*init)(struct thread_info *thread);
2222
int (*enqueue)(struct thread_info *thread);
2323
int (*dequeue)(struct thread_info *thread);
2424
int (*elect)(int switch_type);
2525
};
2626

27-
int sched_select(int sched_type);
27+
int sched_select(int sched_type, struct thread_info *thread);
2828
int sched_enqueue(struct thread_info *thread);
2929
int sched_dequeue(struct thread_info *thread);
3030
int sched_elect(int flags);

kernel/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ struct thread_info *start_kernel(void)
135135
show_page_bitmap(); // init_pages();
136136
kmem_cache_init();
137137

138-
/* select a scheduling policy */
139-
sched_select(SCHED_CLASS);
140-
141138
/* idle_thread is not added to the runqueue */
142139
task_init(&idle_task);
143140
thread_idle =
@@ -161,6 +158,9 @@ struct thread_info *start_kernel(void)
161158
printk("Created main_thread at <%p> with priority=%d\n", thread_main,
162159
thread_main->ti_priority);
163160

161+
/* select a scheduling policy */
162+
sched_select(SCHED_CLASS, thread_main);
163+
164164
/* Reclaim the early-stack physical memory. In the current context, no
165165
* page allocation after this point are allowed. */
166166
printk("Reclaim early stack's physical memory (%d Bytes, order=%d).\n",

kernel/sched.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern const struct sched sched_bitmap;
66

77
static const struct sched *sched;
88

9-
int sched_select(int sched_type)
9+
int sched_select(int sched_type, struct thread_info *thread)
1010
{
1111
switch (sched_type) {
1212
case SCHED_CLASS_RR:
@@ -19,7 +19,7 @@ int sched_select(int sched_type)
1919
return -1;
2020
}
2121

22-
return sched->init();
22+
return sched->init(thread);
2323
}
2424

2525
int sched_enqueue(struct thread_info *thread)

kernel/sched/bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static struct {
1818
.expire = &_expire,
1919
};
2020

21-
static int sched_bitmap_init(void)
21+
static int sched_bitmap_init(__unused struct thread_info *thread)
2222
{
2323
INIT_BITMAP(sched_struct.active);
2424
INIT_BITMAP(sched_struct.expire);

kernel/sched/rr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
static LIST_HEAD(rr_runq);
88
extern struct thread_info *thread_idle;
99

10-
int sched_rr_init(void)
10+
int sched_rr_init(struct thread_info *thread)
1111
{
12+
sched_rr_enqueue(thread);
1213
return 0;
1314
}
1415

0 commit comments

Comments
 (0)