diff --git a/src/include/kernel/syscalls.h b/src/include/kernel/syscalls.h index 6cf90a4..2f5d7d6 100644 --- a/src/include/kernel/syscalls.h +++ b/src/include/kernel/syscalls.h @@ -14,7 +14,7 @@ #define MAX_SYSCALL 12 // for now typedef struct SyscallRequest { - bool busy, queued; + bool busy, queued, unblock; uint64_t function; uint64_t params[4]; diff --git a/src/syscalls/dispatch.c b/src/syscalls/dispatch.c index 32f2811..d680fb2 100644 --- a/src/syscalls/dispatch.c +++ b/src/syscalls/dispatch.c @@ -20,18 +20,22 @@ void syscallDispatchExit(SyscallRequest *req) { void syscallDispatchFork(SyscallRequest *req) { req->ret = fork(req->thread); + req->unblock = true; } void syscallDispatchYield(SyscallRequest *req) { req->ret = yield(req->thread); + req->unblock = true; } void syscallDispatchGetPID(SyscallRequest *req) { req->ret = req->thread->pid; + req->unblock = true; } void syscallDispatchGetTID(SyscallRequest *req) { req->ret = req->thread->tid; + req->unblock = true; } void syscallDispatchGetUID(SyscallRequest *req) { @@ -42,6 +46,8 @@ void syscallDispatchGetUID(SyscallRequest *req) { } else { req->ret = p->user; } + + req->unblock = true; } void syscallDispatchGetGID(SyscallRequest *req) { @@ -52,6 +58,8 @@ void syscallDispatchGetGID(SyscallRequest *req) { } else { req->ret = p->group; } + + req->unblock = true; } void syscallDispatchMSleep(SyscallRequest *req) { @@ -59,7 +67,7 @@ void syscallDispatchMSleep(SyscallRequest *req) { } void (*syscallDispatchTable[])(SyscallRequest *) = { - // group 1: scheduler functions + /* group 1: scheduler functions */ syscallDispatchExit, // 0 - exit() syscallDispatchFork, // 1 - fork() syscallDispatchYield, // 2 - yield() diff --git a/src/syscalls/queue.c b/src/syscalls/queue.c index f6b75e6..e626980 100644 --- a/src/syscalls/queue.c +++ b/src/syscalls/queue.c @@ -96,7 +96,7 @@ int syscallProcess() { platformSetContextStatus(syscall->thread->context, syscall->ret); } - if(syscall->thread->status == THREAD_BLOCKED) { + if((syscall->thread->status == THREAD_BLOCKED) && syscall->unblock) { // this way we prevent accidentally running threads that exit() syscall->thread->status = THREAD_QUEUED; syscall->thread->time = schedTimeslice(syscall->thread, syscall->thread->priority);