peredOS/kernel/thread.h

33 lines
910 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef THREAD_H
#define THREAD_H
#include <stdint.h>
#include <stddef.h>
typedef enum {
THREAD_READY,
THREAD_RUNNING,
THREAD_ZOMBIE
} thread_state_t;
// То, что пушится на стек при переключении
typedef struct {
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t eip;
uint32_t cs;
uint32_t eflags;
} cpu_context_t;
typedef struct thread {
uint32_t id;
uint32_t* esp; // Указатель на текущий топ стека
void* stack_limit; // Чтобы потом делать kfree
thread_state_t state;
struct thread* next;
} thread_t;
void kthread_init(void);
thread_t* kthread_create(void (*entry_point)(void));
void kthread_yield(void);
#endif