Skip to content

Commit

Permalink
feat(ex_15_1): update task sche method & test timer to create task & …
Browse files Browse the repository at this point in the history
…add list_timer
  • Loading branch information
ludics committed Jan 7, 2024
1 parent 2c1d661 commit 00c63ae
Show file tree
Hide file tree
Showing 16 changed files with 1,094 additions and 45 deletions.
6 changes: 5 additions & 1 deletion code/exercises/ex_15_1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ SRCS_C = \
user.c \
trap.c \
plic.c \
timer_structs/list_timer.c \
timer.c \
lock.c \
malloc.c \
xoshiro256ss.c \
timer_structs/list.c \

OBJS = $(SRCS_ASM:.S=.o)
OBJS += $(SRCS_C:.c=.o)
Expand Down Expand Up @@ -45,7 +49,7 @@ debug: all
@echo "Press Ctrl-C and then input 'quit' to exit GDB and QEMU"
@echo "-------------------------------------------------------"
@${QEMU} ${QFLAGS} -kernel os.elf -s -S &
@${GDB} os.elf -q -x ../gdbinit
@${GDB} os.elf -q -x ./gdbinit

.PHONY : code
code: all
Expand Down
23 changes: 23 additions & 0 deletions code/exercises/ex_15_1/gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
display/z $mscratch
display/z $mepc
display/z $mie
display/z $mstatus
display/z $mcause
display/z $a0
display/z $a1
display/z $pc
display/z $t5
display/z $t6

set disassemble-next-line on

b _start
b sched_init
b os_main
b trap_vector
b trap_handler
b schedule
b switch_to

target remote : 1234
c
22 changes: 21 additions & 1 deletion code/exercises/ex_15_1/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ extern void os_main(void);
extern void trap_init(void);
extern void plic_init(void);
extern void timer_init(void);
extern void list_timer_init(void);
extern void mm_init(void);
// extern void mm_test(void);

extern void k_task_delay(uint32_t ticks);

void os_schedule(void) {
// 内核调度
while (1) {
// uart_puts("os_schedule: Activate next task\n");
int id = r_mhartid();
*(uint32_t*)CLINT_MSIP(id) = 1;
uart_puts("os_schedule: Back to OS\n");
k_task_delay(1);
}
}

void start_kernel(void)
{
Expand All @@ -20,11 +36,15 @@ void start_kernel(void)

page_init();

mm_init();
// mm_test();

trap_init();

plic_init();

timer_init();
// timer_init();
list_timer_init();

sched_init();

Expand Down

0 comments on commit 00c63ae

Please sign in to comment.