From f8d989b214681e6a9aa25e0622741197ed4aab30 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 9 Dec 2021 15:56:04 +0100 Subject: [PATCH] Add extra checks when running a new task in nosv --- emu_nosv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/emu_nosv.c b/emu_nosv.c index 2a48677..48129e9 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -90,6 +90,7 @@ pre_task_create(struct ovni_emu *emu) task->id = emu->cur_ev->payload.i32[0]; task->type_id = emu->cur_ev->payload.i32[1]; task->state = TASK_ST_CREATED; + task->thread = NULL; /* Ensure the task id is new */ HASH_FIND_INT(emu->cur_proc->tasks, &task->id, p); @@ -121,6 +122,12 @@ pre_task_execute(struct ovni_emu *emu) if(task == NULL) die("cannot find task with id %d\n", taskid); + if(task->state != TASK_ST_CREATED) + die("task state is not created\n"); + + if(task->thread != NULL) + die("task already has a thread assigned\n"); + if(emu->cur_thread->state != TH_ST_RUNNING) die("thread state is not running\n");