kernel threads

kernel threads and preemptive multitasking
This commit is contained in:
Matheus
2022-08-13 14:00:26 -03:00
parent ac5339453b
commit e7f4245c6d
14 changed files with 274 additions and 44 deletions
+23 -1
View File
@@ -5,18 +5,29 @@
#include <arch/regs.h>
#include <kernel/vfs.h>
#define THREAD_PRIORITY_INTERRUPT 0
#define THREAD_PRIORITY_KERNEL 1
#define THREAD_PRIORITY_USER 2
#define THREAD_STATE_WAITING 0
#define THREAD_STATE_RUNNING 1
#define THREAD_STATE_BLOCKED 2
typedef unsigned long state_t;
struct _proc_t;
typedef struct _thread_t{
struct _thread_t* next;
struct _thread_t* prev;
struct _proc_t* proc;
arch_regs* regs;
size_t state;
state_t state;
void* kernelstack;
void* kernelstackbase;
size_t stacksize;
pid_t tid;
int priority;
} thread_t;
typedef struct _proc_t{
@@ -26,8 +37,19 @@ typedef struct _proc_t{
pid_t pid;
gid_t gid;
uid_t uid;
thread_t** threads;
size_t threadcount;
dirnode_t* root;
dirnode_t* cwd;
} proc_t;
typedef struct{
thread_t* start;
thread_t* end;
int lock;
} sched_queue;
void sched_init();
#endif
+2 -1
View File
@@ -1,6 +1,7 @@
#ifndef _TIMER_H_INCLUDE
#define _TIMER_H_INCLUDE
#include <stdbool.h>
#include <stddef.h>
#include <arch/regs.h>
@@ -14,7 +15,7 @@ typedef struct _timer_req{
} timer_req;
void timer_init();
void timer_add(timer_req* req, size_t us);
void timer_add(timer_req* req, size_t us, bool start);
void timer_resume();
void timer_stop();
void timer_irq(arch_regs* ctx);