45 lines
865 B
C
45 lines
865 B
C
#pragma once
|
|
|
|
#include "list.h"
|
|
#include "memory.h"
|
|
#include "types.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
extern struct task *current_task;
|
|
|
|
enum status { ZOMBIE, THREAD, RUN, WAIT, SLEEP, STOPPED, FORKED };
|
|
enum owner { OWNER_KERNEL, OWNER_USER };
|
|
|
|
#define STACK_SIZE PAGE_SIZE * 4
|
|
|
|
struct task {
|
|
u8 *esp;
|
|
u8 *esp0;
|
|
u32 *cr3; // physical
|
|
u32 *heap; // virtual
|
|
u32 *eip;
|
|
u16 pid;
|
|
u8 status;
|
|
u8 uid;
|
|
struct task *daddy;
|
|
struct task *child;
|
|
struct list **signals;
|
|
struct task *next;
|
|
struct task *prev;
|
|
};
|
|
|
|
void scheduler(void);
|
|
void switch_to_task(struct task *next_task);
|
|
struct task *create_task(u8 uid);
|
|
i8 create_kernel_task(void);
|
|
void remove_task(struct task *task);
|
|
struct task *copy_task(const struct task *task);
|
|
void kfork(struct task *daddy);
|
|
void zombify_task(struct task *task);
|
|
|
|
// utils
|
|
void exec_fn(void (*fn)(void));
|
|
u16 fork(void);
|
|
u16 wait(void);
|