sched: unblock process after blocking read syscall

This commit is contained in:
Michael Shaw 2024-02-19 02:43:51 -05:00 • committed by Michael Shaw
commit a1559a1664
2 changed files with 13 additions and 1 deletions

View file

@ -41,7 +41,17 @@ ssize_t sys_read(int fd, void *buf, size_t count)
if (tmp_buf == NULL)
return -ENOMEM;
ssize_t ret = vfs_read(file, tmp_buf, fdesc->pos, count);
ssize_t ret;
bool blocked = false;
while ((ret = vfs_read(file, tmp_buf, fdesc->pos, count)) == -EAGAIN) {
blocked = true;
proc_block(getpid(), true);
yield();
}
if (blocked)
proc_unblock(getpid());
if (ret > 0)
memcpy(buf, tmp_buf, count);
else

View file

@ -22,6 +22,8 @@ void _start()
if (fd < 0)
exit(1);
write(fd, "shtest: simple userland shell test\n", 35);
promptfd(fd);
char c;