summaryrefslogtreecommitdiff
path: root/kernel/sched
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-28 20:07:50 +0100
committerAnton Kling <anton@kling.gg>2023-11-28 20:07:50 +0100
commit636858dbbd48ed9f5073793b46740302aa202f43 (patch)
treecf976c2b5a61ba055f0877317afdaf6e871df80e /kernel/sched
parent89dc5dd5ba1e9cfe7a8975086c1d5638f8fbbac5 (diff)
Kernel: Add basic IPC and move to microkernel design.
The IPC design is currently a WIP and is nowhere near complete
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/scheduler.c14
-rw-r--r--kernel/sched/scheduler.h4
2 files changed, 17 insertions, 1 deletions
diff --git a/kernel/sched/scheduler.c b/kernel/sched/scheduler.c
index 7d13277..ccc5956 100644
--- a/kernel/sched/scheduler.c
+++ b/kernel/sched/scheduler.c
@@ -17,7 +17,19 @@ u32 next_pid = 0;
extern u32 read_eip(void);
-process_t *get_current_task(void) { return current_task; }
+process_t *get_current_task(void) {
+ return current_task;
+}
+
+bool get_task_from_pid(u32 pid, process_t **out) {
+ for (process_t *tmp = ready_queue; tmp; tmp = tmp->next) {
+ if (tmp->pid == pid) {
+ *out = tmp;
+ return true;
+ }
+ }
+ return false;
+}
void set_signal_handler(int sig, void (*handler)(int)) {
if (sig >= 20 || sig < 0)
diff --git a/kernel/sched/scheduler.h b/kernel/sched/scheduler.h
index f57a319..17e5d56 100644
--- a/kernel/sched/scheduler.h
+++ b/kernel/sched/scheduler.h
@@ -3,8 +3,10 @@
#include <fs/ext2.h>
#include <fs/vfs.h>
#include <halts.h>
+#include <ipc.h>
#include <mmu.h>
#include <signal.h>
+#include <stdbool.h>
#define MAX_PATH 256
#define KEYBOARD_HALT 0
@@ -41,6 +43,7 @@ struct Process {
u32 signal_handler_stack;
void *signal_handlers[20];
PageDirectory *cr3;
+ struct IpcMailbox ipc_mailbox;
vfs_fd_t *file_descriptors[100];
vfs_inode_t *read_halt_inode[100];
vfs_inode_t *write_halt_inode[100];
@@ -59,6 +62,7 @@ struct Process {
int dead;
};
+bool get_task_from_pid(u32 pid, process_t **out);
process_t *get_current_task(void);
int get_free_fd(process_t *p, int allocate);
void free_process(void);