diff --git a/src/emu/nosv/event.c b/src/emu/nosv/event.c index 03d6754..fd85973 100644 --- a/src/emu/nosv/event.c +++ b/src/emu/nosv/event.c @@ -160,6 +160,7 @@ chan_task_switch(struct emu *emu, struct task *prev, struct task *next, char tr) { struct nosv_thread *th = EXT(emu->thread, 'V'); struct chan *ch = th->m.ch; + struct proc *proc = emu->proc; if (!prev || !next) { err("cannot switch to or from a NULL task"); @@ -186,19 +187,25 @@ chan_task_switch(struct emu *emu, struct task *prev, struct task *next, char tr) return -1; } - /* No need to change the rank or app ID as we will switch - * to tasks from same thread */ if (chan_set(&ch[CH_TASKID], value_int64(next->id)) != 0) { err("chan_set taskid failed"); return -1; } - - /* TODO: test when switching to another task with the same type. We - * should emit the same type state value as previous task. */ if (chan_set(&ch[CH_TYPE], value_int64(next->type->gid)) != 0) { err("chan_set type failed"); return -1; } + if (chan_set(&ch[CH_APPID], value_int64(proc->appid)) != 0) { + err("chan_set appid failed"); + return -1; + } + if (proc->rank >= 0) { + struct value vrank = value_int64(proc->rank + 1); + if (chan_set(&ch[CH_RANK], vrank) != 0) { + err("chan_set rank failed"); + return -1; + } + } /* Update the subsystem depending if we are pushing (X) or * poping (E) a task from the stack */ diff --git a/src/emu/nosv/setup.c b/src/emu/nosv/setup.c index 3f1bc1f..9a0b6be 100644 --- a/src/emu/nosv/setup.c +++ b/src/emu/nosv/setup.c @@ -32,6 +32,7 @@ static const int chan_stack[CH_MAX] = { static const int chan_dup[CH_MAX] = { [CH_APPID] = 1, [CH_TYPE] = 1, + [CH_RANK] = 1, }; /* ----------------- pvt ------------------ */ @@ -77,37 +78,19 @@ static const struct pcf_value_label (*pcf_labels[CH_MAX])[] = { [CH_SUBSYSTEM] = &nosv_ss_values, }; -/* ------------- duplicates in prv -------------- */ - -static const long th_prv_flags[CH_MAX] = { - /* Due muxes we need to skip duplicated nulls */ +static const long prv_flags[CH_MAX] = { [CH_TASKID] = PRV_SKIPDUP, - [CH_TYPE] = PRV_SKIPDUP, - [CH_APPID] = PRV_SKIPDUP, + [CH_TYPE] = PRV_EMITDUP, /* Switch to task of same type */ + [CH_APPID] = PRV_EMITDUP, /* Switch to task of same appid */ [CH_SUBSYSTEM] = PRV_SKIPDUP, - [CH_RANK] = PRV_SKIPDUP, + [CH_RANK] = PRV_EMITDUP, /* Switch to task of same rank */ }; -static const long cpu_prv_flags[CH_MAX] = { - [CH_TASKID] = PRV_SKIPDUP, - [CH_TYPE] = PRV_SKIPDUP, - [CH_APPID] = PRV_SKIPDUP, - [CH_SUBSYSTEM] = PRV_SKIPDUP, - [CH_RANK] = PRV_SKIPDUP, -}; - -static const struct model_pvt_spec th_pvt_spec = { +static const struct model_pvt_spec pvt_spec = { .type = pvt_type, .prefix = pcf_prefix, .label = pcf_labels, - .flags = th_prv_flags, -}; - -static const struct model_pvt_spec cpu_pvt_spec = { - .type = pvt_type, - .prefix = pcf_prefix, - .label = pcf_labels, - .flags = cpu_prv_flags, + .flags = prv_flags, }; /* ----------------- tracking ------------------ */ @@ -136,7 +119,7 @@ static const struct model_chan_spec th_chan = { .ch_names = chan_name, .ch_stack = chan_stack, .ch_dup = chan_dup, - .pvt = &th_pvt_spec, + .pvt = &pvt_spec, .track = th_track, }; @@ -145,7 +128,7 @@ static const struct model_chan_spec cpu_chan = { .prefix = model_name, .ch_names = chan_name, .ch_stack = chan_stack, - .pvt = &cpu_pvt_spec, + .pvt = &pvt_spec, .track = cpu_track, };