Add an stronger restriction for task switching

In nOS-V, we can only switch from a running task to another if they are
from the same thread.
This commit is contained in:
Rodrigo Arias 2022-06-02 15:32:40 +02:00
parent 2ac9a76b3b
commit b0e25f29c7

View File

@ -302,10 +302,12 @@ pre_task_switch(struct ovni_emu *emu, struct nosv_task *prev_task,
if(next_task->type->gid == 0) if(next_task->type->gid == 0)
die("next task type id cannot be 0\n"); die("next task type id cannot be 0\n");
chan_set(&th->chan[CHAN_NOSV_TASKID], next_task->id); if(prev_task->thread != next_task->thread)
die("cannot switch to a task of another thread\n");
/* No need to change the rank, as we can only switch to tasks of /* No need to change the rank or app ID, as we can only switch
* the same loom (with same rank) */ * to tasks of the same thread */
chan_set(&th->chan[CHAN_NOSV_TASKID], next_task->id);
/* FIXME: We should emit a PRV event even if we are switching to /* FIXME: We should emit a PRV event even if we are switching to
* the same type event, to mark the end of the current task. For * the same type event, to mark the end of the current task. For