From eee7d9ed4e5d9b0be7c792328dc828a682b5af67 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Sun, 16 Jun 2024 22:31:14 -0400 Subject: [PATCH] syscall: remove `PROC_BLOCKED_SYSCALL` Rather than yielding, currently just wait for the syscall to be executed. Signed-off-by: Michael Shaw --- include/kernel/proc.h | 1 - sched/proc.c | 1 - sched/syscall.c | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/kernel/proc.h b/include/kernel/proc.h index 9aad00f..38581b1 100644 --- a/include/kernel/proc.h +++ b/include/kernel/proc.h @@ -13,7 +13,6 @@ #define PROC_RUNNING 0 #define PROC_STOPPED 1 #define PROC_BLOCKED 2 -#define PROC_BLOCKED_SYSCALL 3 #define STDIN_FILENO 0 #define STDOUT_FILENO 1 diff --git a/sched/proc.c b/sched/proc.c index e2ba456..4f9cc6a 100644 --- a/sched/proc.c +++ b/sched/proc.c @@ -132,7 +132,6 @@ void schedule() spinlock_acquire(&proc->lock); switch (proc->state) { - case PROC_BLOCKED_SYSCALL: case PROC_STOPPED: proc->state = PROC_RUNNING; spinlock_release(&proc->lock); diff --git a/sched/syscall.c b/sched/syscall.c index f0fa08f..b76dcee 100644 --- a/sched/syscall.c +++ b/sched/syscall.c @@ -46,9 +46,9 @@ ssize_t sys_read(int fd, void *buf, size_t count) return -ENOMEM; ssize_t ret; + while ((ret = vfs_read(file, tmp_buf, fdesc->pos, count)) == -EAGAIN) { - proc->state = PROC_BLOCKED_SYSCALL; - schedule(); + proc->state = PROC_BLOCKED; } proc->state = PROC_RUNNING;