implement basic multitasking
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#ifndef TASK_H
|
||||
#define TASK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum TaskState
|
||||
{
|
||||
Ready,
|
||||
Running,
|
||||
Waiting,
|
||||
Terminated
|
||||
} TaskState;
|
||||
|
||||
typedef void (*EntryPoint)(void);
|
||||
|
||||
typedef struct Process
|
||||
{
|
||||
uint32_t pid; // Process ID
|
||||
TaskState state; // Process state
|
||||
uintptr_t programCounter; // Program Counter
|
||||
uintptr_t* stackBase; // Top of the stack
|
||||
uintptr_t* stackPointer; // Stack Pointer
|
||||
uint32_t flags; // Status/Flags register
|
||||
struct Process* next; // Pointer to the next task in the list
|
||||
} Process;
|
||||
|
||||
Process* task_create(EntryPoint func);
|
||||
void scheduler_init();
|
||||
void schedule();
|
||||
void scheduler_lock();
|
||||
void scheduler_unlock();
|
||||
#endif
|
||||
Reference in New Issue
Block a user