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.
This commit is contained in:
Kevin Sala 2021-10-13 14:44:20 +02:00 committed by Rodrigo Arias
parent f1fa68e4df
commit 7def854b8b
3 changed files with 100 additions and 0 deletions

4
emu.h
View File

@ -41,6 +41,10 @@ enum nosv_thread_ss_state {
ST_MEM_ALLOCATING = 9, ST_MEM_ALLOCATING = 9,
ST_TASK_RUNNING = 10, ST_TASK_RUNNING = 10,
ST_NOSV_CODE = 11, ST_NOSV_CODE = 11,
ST_PAUSE = 12,
ST_YIELD = 13,
ST_WAITFOR = 14,
ST_SCHEDPOINT = 15,
ST_BAD = 666, ST_BAD = 666,
}; };

View File

@ -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 static void
pre_submit(struct ovni_emu *emu) pre_submit(struct ovni_emu *emu)
{ {
@ -429,6 +517,10 @@ hook_pre_nosv(struct ovni_emu *emu)
case 'S': pre_sched(emu); break; case 'S': pre_sched(emu); break;
case 'U': pre_submit(emu); break; case 'U': pre_submit(emu); break;
case 'M': pre_memory(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; case 'C': pre_code(emu); break;
default: default:
break; break;

4
pcf.c
View File

@ -125,6 +125,10 @@ struct event_value ss_values[] = {
{ ST_SCHED_SUBMITTING, "Scheduler: Submitting" }, { ST_SCHED_SUBMITTING, "Scheduler: Submitting" },
{ ST_TASK_RUNNING, "Task: Running" }, { ST_TASK_RUNNING, "Task: Running" },
{ ST_NOSV_CODE, "nOS-V code" }, { 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_SEND, "EV Scheduler: Send task" },
{ EV_SCHED_RECV, "EV Scheduler: Recv task" }, { EV_SCHED_RECV, "EV Scheduler: Recv task" },
{ EV_SCHED_SELF, "EV Scheduler: Self-assign task" }, { EV_SCHED_SELF, "EV Scheduler: Self-assign task" },