#pragma once
#include <stdint.h>
#include "mmu.h"

#define MAX_TASKS 32
#define MAX_CPUS  4

typedef enum { TASK_READY, TASK_RUNNING, TASK_WAITING, TASK_TERMINATED } task_state;

typedef struct {
    void (*entry)(void);
    unsigned long sp;
    task_state state;
    int id;
    int last_core;
    pagedir_t* pgdir;
} task_t;

extern task_t  tasks[MAX_TASKS];
extern int     task_count;
extern task_t* current_task[MAX_CPUS];

void task_create(void (*fn)(void));
int  task_create_user_elf(uint64_t entry, pagedir_t*);
int  task_kill(int id);
void scheduler_yield(void);
