Update scheduler.h

This commit is contained in:
2025-11-19 08:44:15 -08:00
committed by GitHub
parent e9a78c835a
commit 9de9cc6523

View File

@@ -4,18 +4,21 @@
#include <stdint.h> #include <stdint.h>
#define MAX_TASKS 8 #define MAX_TASKS 8
#define STACK_SIZE 1024 #define STACK_SIZE 1024 // in bytes
typedef struct task { typedef struct task {
uint32_t id; uint32_t id;
void (*entry)(void);
uint32_t *stack_ptr; // The most important field:
// Where was the stack pointer when we last left this task?
uint32_t *stack_ptr;
struct task *next; struct task *next;
} task_t; } task_t;
void scheduler_init(); void scheduler_init();
void scheduler_add_task(void (*entry)(void)); void scheduler_add_task(void (*entry)(void));
void scheduler_schedule(); void scheduler_schedule();
void scheduler_yield(); // Optional for cooperative scheduling void scheduler_yield();
#endif // SCHEDULER_H #endif // SCHEDULER_H