28 lines
459 B
C
28 lines
459 B
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#define STACK_SIZE PAGE_SIZE * 4
|
|
#define CURRENT_TCB ((struct tcb *)current_tcb->content)
|
|
|
|
typedef uint16_t tid_t;
|
|
|
|
typedef enum {
|
|
NEW,
|
|
RUNNING,
|
|
WAITING,
|
|
STOPPED,
|
|
} state_t;
|
|
|
|
struct tcb {
|
|
uint32_t *esp;
|
|
uint32_t *esp0;
|
|
tid_t tid;
|
|
state_t state;
|
|
struct pcb *process;
|
|
};
|
|
|
|
struct tcb *create_thread(struct pcb *process, void (*entry)(void));
|
|
void delete_thread(struct tcb *thread);
|
|
void switch_thread(uint32_t *esp);
|