From 7def854b8bdf173b5cd9f2c870b36b8b77a4d6a3 Mon Sep 17 00:00:00 2001 From: Kevin Sala Date: Wed, 13 Oct 2021 14:44:20 +0200 Subject: [PATCH] Adding subsystem states for some nOS-V API calls This commit includes states for the nosv_pause, nosv_yield, and nosv_waitfor and nosv_scheduling_point API calls. --- emu.h | 4 +++ emu_nosv.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pcf.c | 4 +++ 3 files changed, 100 insertions(+) diff --git a/emu.h b/emu.h index 194f5ec..c57b076 100644 --- a/emu.h +++ b/emu.h @@ -41,6 +41,10 @@ enum nosv_thread_ss_state { ST_MEM_ALLOCATING = 9, ST_TASK_RUNNING = 10, ST_NOSV_CODE = 11, + ST_PAUSE = 12, + ST_YIELD = 13, + ST_WAITFOR = 14, + ST_SCHEDPOINT = 15, ST_BAD = 666, }; diff --git a/emu_nosv.c b/emu_nosv.c index 1fe9e88..f71e49e 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -351,6 +351,94 @@ pre_sched(struct ovni_emu *emu) } } +static void +pre_pause(struct ovni_emu *emu) +{ + struct ovni_ethread *th; + struct ovni_chan *chan_th; + + th = emu->cur_thread; + chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM]; + + switch(emu->cur_ev->header.value) + { + case '[': + chan_push(chan_th, ST_PAUSE); + break; + case ']': + chan_pop(chan_th, ST_PAUSE); + break; + default: + break; + } +} + +static void +pre_yield(struct ovni_emu *emu) +{ + struct ovni_ethread *th; + struct ovni_chan *chan_th; + + th = emu->cur_thread; + chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM]; + + switch(emu->cur_ev->header.value) + { + case '[': + chan_push(chan_th, ST_YIELD); + break; + case ']': + chan_pop(chan_th, ST_YIELD); + break; + default: + break; + } +} + +static void +pre_waitfor(struct ovni_emu *emu) +{ + struct ovni_ethread *th; + struct ovni_chan *chan_th; + + th = emu->cur_thread; + chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM]; + + switch(emu->cur_ev->header.value) + { + case '[': + chan_push(chan_th, ST_WAITFOR); + break; + case ']': + chan_pop(chan_th, ST_WAITFOR); + break; + default: + break; + } +} + +static void +pre_schedpoint(struct ovni_emu *emu) +{ + struct ovni_ethread *th; + struct ovni_chan *chan_th; + + th = emu->cur_thread; + chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM]; + + switch(emu->cur_ev->header.value) + { + case '[': + chan_push(chan_th, ST_SCHEDPOINT); + break; + case ']': + chan_pop(chan_th, ST_SCHEDPOINT); + break; + default: + break; + } +} + static void pre_submit(struct ovni_emu *emu) { @@ -429,6 +517,10 @@ hook_pre_nosv(struct ovni_emu *emu) case 'S': pre_sched(emu); break; case 'U': pre_submit(emu); break; case 'M': pre_memory(emu); break; + case 'P': pre_pause(emu); break; + case 'I': pre_yield(emu); break; + case 'W': pre_waitfor(emu); break; + case 'D': pre_schedpoint(emu); break; case 'C': pre_code(emu); break; default: break; diff --git a/pcf.c b/pcf.c index a4335df..65d6348 100644 --- a/pcf.c +++ b/pcf.c @@ -125,6 +125,10 @@ struct event_value ss_values[] = { { ST_SCHED_SUBMITTING, "Scheduler: Submitting" }, { ST_TASK_RUNNING, "Task: Running" }, { ST_NOSV_CODE, "nOS-V code" }, + { ST_PAUSE, "API: Pause" }, + { ST_YIELD, "API: Yield" }, + { ST_WAITFOR, "API: Waitfor" }, + { ST_SCHEDPOINT, "API: Scheduling point" }, { EV_SCHED_SEND, "EV Scheduler: Send task" }, { EV_SCHED_RECV, "EV Scheduler: Recv task" }, { EV_SCHED_SELF, "EV Scheduler: Self-assign task" },