#pragma once #include #include #include typedef int32_t (*thread_func_t)(uint64_t); typedef enum: uint32_t { THREAD_STATUS_RUNABLE = 0, THREAD_STATUS_WAIT = 1, THREAD_STATUS_EXIT = 2, THREAD_STATUS_ZOMBIE = 3, } thread_status_t; typedef struct { uint64_t x19, x20; uint64_t x21, x22; uint64_t x23, x24; uint64_t x25, x26; uint64_t x27, x28; uint64_t fp, lr; uint64_t sp; } cpu_state_t; typedef struct thread { thread_func_t func; uint64_t param; thread_status_t status; int32_t retcode; void *stack; size_t stack_size; cpu_state_t *regs; process_t *process; } thread_t; // thread.S void context_switch(void *from, void *to, thread_t *th); // thread.c void thread_init(void); void run_thread(thread_func_t func, uint64_t param); void schedule(void); #define yield schedule thread_t *get_current(void); extern queue_t *global_run_queue; extern queue_t *global_wait_queue; extern queue_t *global_gc_queue;