sched: fix page faulting on process switching

This is the first version of the kernel with fully isolated threads for
user and kernel tasks, where process 0 is only used for scheduling and
interrupt handling.

User process have a "buddy" kernel process that handles its tasks in the
kernel.

This system allows for easy blocking of threads without much need for
thought. Just `sswtch` in an infinite read loop, and your userspace
process will be blocked.

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
Michael Shaw 2025-02-11 21:11:49 -05:00
commit f92e88597d
8 changed files with 125 additions and 30 deletions

View file

@ -65,8 +65,6 @@ ssize_t sys_read(int fd, void *buf, size_t count)
ssize_t ret = vfs_read(file, tmp_buf, fdesc->pos, count);
proc->state = PROC_RUNNING;
if (ret > 0)
memcpy(buf, tmp_buf, count);
else
@ -147,10 +145,6 @@ void sys_exit(int status)
if (proc == NULL)
return;
spinlock_acquire(&proc->lock);
proc->state = PROC_STOPPED;
spinlock_release(&proc->lock);
proc_term(pid);
kprintf("(syscall)Process %d exited with status 0x%x\n", pid, status);