[feat] 100Hz task switch
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#define TASK_STACK_SIZE (PAGE_SIZE * 4) // 16 KB kernel stack per task
|
||||
#define TASK_MAX 32
|
||||
#define TASK_NAME_LEN 32
|
||||
#define TIME_SLICE_DEFAULT 5 // 5 ticks = 50ms at 100 Hz
|
||||
|
||||
typedef enum {
|
||||
TASK_STATE_READY,
|
||||
@@ -21,6 +22,7 @@ typedef struct task {
|
||||
char name[TASK_NAME_LEN];
|
||||
void* stack_base; // base address of kernel stack
|
||||
struct task* next; // circular linked list
|
||||
UINT32 time_slice; // remaining ticks before preemption
|
||||
} task_t;
|
||||
|
||||
// Create a new task. Returns task pointer or NULL on failure.
|
||||
@@ -37,3 +39,6 @@ void task_exit(void);
|
||||
|
||||
// Get current running task
|
||||
task_t* scheduler_current(void);
|
||||
|
||||
// Timer tick handler — called by PIT IRQ 0, drives preemption
|
||||
void scheduler_tick(void);
|
||||
|
||||
Reference in New Issue
Block a user