Skip to content

Commit aa03033

Browse files
committed
Makefile: Add SCHED flags to switch scheduler
1 parent 8ca0737 commit aa03033

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ deps := $(OBJS:%.o=.%.o.d)
3939

4040
.PHONY: all check clean distclean
4141

42-
all: $(CMSIS)/$(TARGET) $(NAME).lds $(NAME).bin
42+
all: $(CMSIS)/$(TARGET) $(NAME).lds $(NAME).bin SCHED_FLAGS
4343

4444
# generic build rules
4545
include mk/flags.mk

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ $ python -m tests
1515
# Run partial test with command line tools
1616
$ python -m tests fs_1 cond_2
1717
```
18+
19+
## Makefile
20+
21+
You can switch scheduler by makefile flags:
22+
23+
```
24+
# Using bitmap scheduler
25+
26+
$ make SCHED=BITMAP
27+
28+
# Using RR scheduler
29+
30+
$ make SCHED=RR
31+
```

kernel/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ void init_IRQ(void);
4545
struct task_info idle_task;
4646
struct task_info main_task;
4747

48+
/* Select scheduler */
49+
#ifndef SCHED_CLASS
50+
#define SCHED_CLASS SCHED_CLASS_BITMAP
51+
#endif
52+
4853
void print_version(void)
4954
{
5055
char buf[] = {0, 0};
@@ -131,7 +136,7 @@ struct thread_info *start_kernel(void)
131136
kmem_cache_init();
132137

133138
/* select a scheduling policy */
134-
sched_select(SCHED_CLASS_BITMAP);
139+
sched_select(SCHED_CLASS);
135140

136141
/* idle_thread is not added to the runqueue */
137142
task_init(&idle_task);

mk/flags.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ CFLAGS += \
2424
CFLAGS += \
2525
-D CONFIG_KERNEL_STACK_CHECKING
2626

27+
# Scheduler
28+
ifdef SCHED
29+
CFLAGS += -D SCHED_CLASS=SCHED_CLASS_$(SCHED)
30+
SCHED_FLAGS:
31+
$(Q)$(RM) kernel/main.o
32+
endif
33+
2734
LDFLAGS += \
2835
-nostartfiles -specs=nano.specs \
2936
-Wl,-Map=$(NAME).map -Wl,-Tpiko.lds -Wl,--gc-sections

0 commit comments

Comments
 (0)