From 4536dc81b4be9a62328826455664cd6d696df8fb Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sun, 25 Feb 2024 01:45:19 +0100 Subject: IPC: Inform the scheduler the process is waiting for a IPC message --- kernel/cpu/int_syscall.s | 1 + kernel/ipc.c | 11 ++++++++++- kernel/ipc.h | 2 ++ kernel/sched/scheduler.c | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel/cpu/int_syscall.s b/kernel/cpu/int_syscall.s index b2c0de9..bda7312 100644 --- a/kernel/cpu/int_syscall.s +++ b/kernel/cpu/int_syscall.s @@ -2,6 +2,7 @@ .global int_syscall .extern syscall_functions int_syscall: +sti push ebp mov ebp,esp push edi diff --git a/kernel/ipc.c b/kernel/ipc.c index bce346a..eb7c1b7 100644 --- a/kernel/ipc.c +++ b/kernel/ipc.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -45,6 +44,16 @@ int ipc_get_mailbox(u32 id, struct IpcMailbox **out) { return 1; } +int ipc_has_data(process_t *p) { + if (!p) { + p = get_current_task(); + } + struct IpcMailbox *handler = &p->ipc_mailbox; + u32 read_ptr = handler->read_ptr; + struct IpcMessage *ipc_message = &handler->data[read_ptr]; + return ipc_message->is_used; +} + int ipc_read(u8 *buffer, u32 length, u32 *sender_pid) { struct IpcMailbox *handler = &get_current_task()->ipc_mailbox; diff --git a/kernel/ipc.h b/kernel/ipc.h index ae67f71..d8db074 100644 --- a/kernel/ipc.h +++ b/kernel/ipc.h @@ -1,3 +1,4 @@ +#include #ifndef IPC_H #define IPC_H #include @@ -23,4 +24,5 @@ bool ipc_register_endpoint(u32 endpoint); int ipc_write_to_process(int pid, u8 *buffer, u32 length); int ipc_write(int ipc_id, u8 *buffer, u32 length); int ipc_read(u8 *buffer, u32 length, u32 *sender_pid); +int ipc_has_data(process_t *p); #endif diff --git a/kernel/sched/scheduler.c b/kernel/sched/scheduler.c index e34e7a7..949cdf2 100644 --- a/kernel/sched/scheduler.c +++ b/kernel/sched/scheduler.c @@ -373,6 +373,12 @@ int is_halted(process_t *process) { } } + if (process->is_halted) { + if (ipc_has_data(process)) { + return 0; + } + } + if (isset_fdhalt(process)) { return 1; } -- cgit v1.2.3