sched: unblock process after blocking read syscall
This commit is contained in:
parent
05103a8122
commit
a1559a1664
2 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ void _start()
|
|||
if (fd < 0)
|
||||
exit(1);
|
||||
|
||||
write(fd, "shtest: simple userland shell test\n", 35);
|
||||
|
||||
promptfd(fd);
|
||||
|
||||
char c;
|
||||
|
|
|
|||
Loading…
Reference in a new issue