sched: copy serial date to userspace on trap

This commit is contained in:
Michael Shaw 2024-06-26 23:55:19 -04:00
commit 8ac4b2e260
2 changed files with 5 additions and 2 deletions

View file

@ -86,12 +86,14 @@ ssize_t serial_read(char *buf)
char c;
ret = ringbuf_read(tty0->data, &c, 1);
struct proc *proc = proc_find(getpid());
while ((ret = ringbuf_read(tty0->data, &c, 1)) <= 0) {
struct proc *proc = proc_find(getpid());
proc_block(proc, tty0, buf, true, 1);
sswtch();
}
copy_to_user(proc, buf, &c, 1);
return ret;
}

View file

@ -167,8 +167,9 @@ void schedule()
break;
case PROC_BLOCKED:
if (!sem_trywait(&proc->block_sem))
proc_unblock(proc->pid);
proc->state = PROC_STOPPED;
spinlock_release(&proc->lock);
break;
case PROC_RUNNING:
spinlock_release(&proc->lock);
break;