From 52ba53ffda0bef42787c256f4f08dba8a8f0180b Mon Sep 17 00:00:00 2001 From: Kevin Sala Date: Fri, 15 Oct 2021 11:31:23 +0200 Subject: [PATCH] Gathering nOS-V API instrumentation as new subnamespace --- emu.h | 9 +++++---- emu_nosv.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- pcf.c | 9 +++++---- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/emu.h b/emu.h index da7da68..63610d3 100644 --- a/emu.h +++ b/emu.h @@ -41,10 +41,11 @@ enum nosv_ss_values { ST_NOSV_MEM_ALLOCATING = 9, ST_NOSV_TASK_RUNNING = 10, ST_NOSV_CODE = 11, - ST_NOSV_PAUSE = 12, - ST_NOSV_YIELD = 13, - ST_NOSV_WAITFOR = 14, - ST_NOSV_SCHEDPOINT = 15, + ST_NOSV_API_SUBMIT = 12, + ST_NOSV_API_PAUSE = 13, + ST_NOSV_API_YIELD = 14, + ST_NOSV_API_WAITFOR = 15, + ST_NOSV_API_SCHEDPOINT = 16, EV_NOSV_SCHED_RECV = 50, EV_NOSV_SCHED_SEND = 51, diff --git a/emu_nosv.c b/emu_nosv.c index 221b2b2..946fc8f 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -351,6 +351,52 @@ pre_sched(struct ovni_emu *emu) } } +static void +pre_api(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 's': + chan_push(chan_th, ST_NOSV_API_SUBMIT); + break; + case 'S': + chan_pop(chan_th, ST_NOSV_API_SUBMIT); + break; + case 'p': + chan_push(chan_th, ST_NOSV_API_PAUSE); + break; + case 'P': + chan_pop(chan_th, ST_NOSV_API_PAUSE); + break; + case 'y': + chan_push(chan_th, ST_NOSV_API_YIELD); + break; + case 'Y': + chan_pop(chan_th, ST_NOSV_API_YIELD); + break; + case 'w': + chan_push(chan_th, ST_NOSV_API_WAITFOR); + break; + case 'W': + chan_pop(chan_th, ST_NOSV_API_WAITFOR); + break; + case 'c': + chan_push(chan_th, ST_NOSV_API_SCHEDPOINT); + break; + case 'C': + chan_pop(chan_th, ST_NOSV_API_SCHEDPOINT); + break; + default: + break; + } +} + static void pre_ss(struct ovni_emu *emu, int st) { @@ -362,7 +408,7 @@ pre_ss(struct ovni_emu *emu, int st) switch(emu->cur_ev->header.value) { - case '[': + case '[': chan_push(chan_th, st); break; case ']': @@ -387,11 +433,8 @@ hook_pre_nosv(struct ovni_emu *emu) case 'S': pre_sched(emu); break; case 'U': pre_ss(emu, ST_NOSV_SCHED_SUBMITTING); break; case 'M': pre_ss(emu, ST_NOSV_MEM_ALLOCATING); break; - case 'P': pre_ss(emu, ST_NOSV_PAUSE); break; - case 'I': pre_ss(emu, ST_NOSV_YIELD); break; - case 'W': pre_ss(emu, ST_NOSV_WAITFOR); break; - case 'D': pre_ss(emu, ST_NOSV_SCHEDPOINT); break; case 'C': pre_ss(emu, ST_NOSV_CODE); break; + case 'A': pre_api(emu); break; default: break; } diff --git a/pcf.c b/pcf.c index e768cf4..ce25e1b 100644 --- a/pcf.c +++ b/pcf.c @@ -125,10 +125,11 @@ struct event_value nosv_ss_values[] = { { ST_NOSV_SCHED_SUBMITTING, "Scheduler: Submitting" }, { ST_NOSV_TASK_RUNNING, "Task: Running" }, { ST_NOSV_CODE, "nOS-V code" }, - { ST_NOSV_PAUSE, "API: Pause" }, - { ST_NOSV_YIELD, "API: Yield" }, - { ST_NOSV_WAITFOR, "API: Waitfor" }, - { ST_NOSV_SCHEDPOINT, "API: Scheduling point" }, + { ST_NOSV_API_SUBMIT, "API: Submit" }, + { ST_NOSV_API_PAUSE, "API: Pause" }, + { ST_NOSV_API_YIELD, "API: Yield" }, + { ST_NOSV_API_WAITFOR, "API: Waitfor" }, + { ST_NOSV_API_SCHEDPOINT, "API: Scheduling point" }, { EV_NOSV_SCHED_SEND, "EV Scheduler: Send task" }, { EV_NOSV_SCHED_RECV, "EV Scheduler: Recv task" }, { EV_NOSV_SCHED_SELF, "EV Scheduler: Self-assign task" },