Keep the thread set after the task ends

Allows the emulator to check when an inner task ends the next in the
stack has the same thread as before.
This commit is contained in:
Rodrigo Arias 2022-06-02 15:43:42 +02:00
parent b0e25f29c7
commit c40348e2a8
2 changed files with 6 additions and 1 deletions

3
emu.h
View File

@ -117,6 +117,9 @@ struct nosv_task_type {
struct nosv_task {
uint32_t id;
struct nosv_task_type *type;
/* The thread that has began to execute the task. It cannot
* change after being set, even if the task ends. */
struct ovni_ethread *thread;
enum nosv_task_state state;
UT_hash_handle hh;

View File

@ -231,7 +231,9 @@ pre_task_end(struct ovni_emu *emu)
die("task is assigned to a different thread\n");
task->state = TASK_ST_DEAD;
task->thread = NULL;
/* Don't unset the thread from the task, as it will be used
* later to ensure we switch to tasks of the same thread. */
DL_DELETE(emu->cur_thread->task_stack, task);