mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-12-26 17:19:04 +00:00
initial versioin
This commit is contained in:
31
code/os/06-interrupts/user.c
Normal file
31
code/os/06-interrupts/user.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "os.h"
|
||||
|
||||
#define DELAY 1000
|
||||
|
||||
void user_task0(void)
|
||||
{
|
||||
uart_puts("Task 0: Created!\n");
|
||||
while (1) {
|
||||
uart_puts("Task 0: Running...\n");
|
||||
task_delay(DELAY);
|
||||
task_yield();
|
||||
}
|
||||
}
|
||||
|
||||
void user_task1(void)
|
||||
{
|
||||
uart_puts("Task 1: Created!\n");
|
||||
while (1) {
|
||||
uart_puts("Task 1: Running...\n");
|
||||
task_delay(DELAY);
|
||||
task_yield();
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTICE: DON'T LOOP INFINITELY IN main() */
|
||||
void os_main(void)
|
||||
{
|
||||
task_create(user_task0);
|
||||
task_create(user_task1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user