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

@ -27,6 +27,23 @@ void _start()
char buf[256];
int n;
/* fork test */
pid_t pid = fork();
if (pid < 0) {
write(fd, "fork failed\n", 12);
exit(1);
}
if (pid == 0) {
write(fd, "child\n", 6);
while (1)
;
} else {
write(fd, "parent\n", 7);
}
/* rw test */
while ((n = read(fd, buf, 256)) > 0) {
write(fd, buf, n);
}