From 9727f0bbfa437116aa9230b3ba83665fed471558 Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 27 Jul 2020 18:01:24 -0500 Subject: [PATCH] Fix allowing unblocking of exited/ready/running threads --- kernel/tasking.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/tasking.c b/kernel/tasking.c index 5c460c1..285dde1 100644 --- a/kernel/tasking.c +++ b/kernel/tasking.c @@ -300,6 +300,10 @@ void tasking_unblock(pid_t pid,pid_t tid) { serial_printf("Error! Got wrong thread! (Wanted TID %d, got TID %d)\n",tid,thread->tid); halt(); } + if (thread->state==THREAD_EXITED||thread->state==THREAD_READY||thread->state==THREAD_RUNNING) { + serial_printf("Tried to unblock an exited/ready/running thread!\n"); + return; + } thread->state=THREAD_READY; if (!is_proc_scheduled(thread->process->pid)) { // Link the thread onto the list of ready to run threads