sched: finish preparing scheduler for rewrite

This commit is contained in:
Matheus
2024-09-21 23:06:37 -03:00
parent cc6477d46d
commit 0bff52b41e
19 changed files with 332 additions and 330 deletions
+5
View File
@@ -13,6 +13,9 @@
#include <kernel/thread.h>
#define PROC_STATE_NORMAL 0
#define PROC_STATE_ZOMBIE 1
typedef struct proc_t {
mutex_t mutex;
int refcount;
@@ -107,5 +110,7 @@ int proc_signal_all(int signal, proc_t *sender);
void proc_stop_other_threads(void);
pid_t proc_allocate_pid(void);
void proc_init(void);
void proc_exit(void);
void proc_run_init();
#endif
+9 -29
View File
@@ -1,26 +1,8 @@
#ifndef _SCHEDULER_H
#define _SCHEDULER_H
#include <arch/context.h>
#include <kernel/vmm.h>
#include <kernel/abi.h>
#include <kernel/vfs.h>
#include <semaphore.h>
#include <mutex.h>
#include <kernel/signal.h>
#include <kernel/itimer.h>
#include <kernel/event.h>
#include <kernel/proc.h>
#define SCHED_THREAD_FLAGS_QUEUED 1
#define SCHED_THREAD_FLAGS_RUNNING 2
#define SCHED_THREAD_FLAGS_SLEEP 4
#define SCHED_THREAD_FLAGS_INTERRUPTIBLE 8
#define SCHED_THREAD_FLAGS_PREEMPTED 16
#define SCHED_THREAD_FLAGS_DEAD 32
#define SCHED_PROC_STATE_NORMAL 0
#define SCHED_PROC_STATE_ZOMBIE 1
#include <kernel/thread.h>
#define SCHED_WAKEUP_REASON_NORMAL 0
#define SCHED_WAKEUP_REASON_INTERRUPTED -1
@@ -29,18 +11,16 @@
#define INTERP_BASE (void *)0x00000beef0000000
void sched_init();
void sched_runinit();
__attribute__((noreturn)) void sched_threadexit();
void sched_ap_entry();
void sched_queue(thread_t *thread);
void sched_stopcurrentthread();
int sched_yield();
void sched_preparesleep(bool interruptible);
bool sched_wakeup(thread_t *thread, int reason);
thread_t *sched_newthread(void *ip, size_t kstacksize, int priority, proc_t *proc, void *ustack);
void sched_destroythread(thread_t *);
void sched_targetcpu(struct cpu_t *cpu);
void sched_stop_current_thread();
void sched_prepare_sleep(bool interruptible);
void sched_target_cpu(struct cpu_t *cpu);
void sched_reschedule_on_cpu(struct cpu_t *cpu, bool target);
void sched_sleepus(size_t us);
void sched_apentry();
void sched_sleep_us(size_t us);
int sched_yield();
#endif
+12
View File
@@ -5,6 +5,14 @@
#include <kernel/vmm.h>
#include <kernel/abi.h>
#include <kernel/signal.h>
#include <kernel/event.h>
#define THREAD_FLAGS_QUEUED 1
#define THREAD_FLAGS_RUNNING 2
#define THREAD_FLAGS_SLEEP 4
#define THREAD_FLAGS_INTERRUPTIBLE 8
#define THREAD_FLAGS_PREEMPTED 16
#define THREAD_FLAGS_DEAD 32
struct proc_t;
@@ -46,4 +54,8 @@ typedef struct thread_t {
} signals;
} thread_t;
__attribute__((noreturn)) void sched_threadexit();
thread_t *sched_newthread(void *ip, size_t kstacksize, int priority, struct proc_t *proc, void *ustack);
void sched_destroythread(thread_t *);
#endif