35 lines
577 B
C
35 lines
577 B
C
#include <stdint.h>
|
|
|
|
#pragma once
|
|
|
|
typedef enum proc_state {
|
|
ZOMBIE = 4,
|
|
RUNNING = 3,
|
|
READY = 2,
|
|
SLEEPING = 1,
|
|
UNUSED = 0
|
|
}proc_state;
|
|
|
|
struct context {
|
|
uint64_t r15, r14, r13, r12, rbp, rbx, rip;
|
|
};
|
|
|
|
struct thread {
|
|
struct thread *next;
|
|
struct thread *prev;
|
|
uint64_t *mem;
|
|
uint64_t *kstack;
|
|
proc_state state;
|
|
uint16_t pid;
|
|
struct context *context;
|
|
char name[8];
|
|
};
|
|
|
|
void scheduler_init();
|
|
[[noreturn]] void sched();
|
|
void yield();
|
|
|
|
#define PROC_MAX 512 // Max number of processes
|
|
|
|
#define INITIAL_STACK_SIZE 0x10000
|
|
|