mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 13:48:21 +00:00
kernel threads
kernel threads and preemptive multitasking
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
typedef int wint_t;
|
||||
|
||||
bool ignoresign = false;
|
||||
|
||||
char* __int_str(uintmax_t i, char b[], int base, bool plusSignIfNeeded, bool spaceSignIfNeeded,
|
||||
int paddingNo, bool justify, bool zeroPad) {
|
||||
@@ -262,10 +261,8 @@ int vprintf (const char* format, va_list list)
|
||||
{
|
||||
|
||||
size_t integer = va_arg(list, size_t);
|
||||
ignoresign = true;
|
||||
__int_str(integer, intStrBuffer, base, plusSign, spaceNoSign, lengthSpec, leftJustify, zeroPad);
|
||||
displayString(intStrBuffer, &chars);
|
||||
ignoresign = false;
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
|
||||
Reference in New Issue
Block a user