From b60c6da764340623f9a7e1f21740e7cce17100e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 23 Sep 2021 12:41:43 +0200 Subject: [PATCH] Emit sched fake events as well --- emu.c | 1 + emu_nosv.c | 9 +++++---- emu_nosv_ss.c | 54 ++++++++++++++++++++++++++++++++++++--------------- pcf.c | 3 +++ 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/emu.c b/emu.c index 280712e..50230a8 100644 --- a/emu.c +++ b/emu.c @@ -113,6 +113,7 @@ hook_post(struct ovni_emu *emu) switch(emu->cur_ev->header.model) { case 'O': hook_post_ovni(emu); break; + case 'V': hook_post_nosv(emu); break; default: //dbg("unknown model %c\n", emu->cur_ev->model); break; diff --git a/emu_nosv.c b/emu_nosv.c index 13a7fd2..8e62240 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -290,7 +290,8 @@ hook_emit_nosv(struct ovni_emu *emu) hook_emit_nosv_ss(emu); } -struct hook_entry pre_hooks[] = { - { "VTc", pre_task_create }, - { "VTx", pre_task_create }, -}; +void +hook_post_nosv(struct ovni_emu *emu) +{ + hook_post_nosv_ss(emu); +} diff --git a/emu_nosv_ss.c b/emu_nosv_ss.c index e91256c..79a7c2c 100644 --- a/emu_nosv_ss.c +++ b/emu_nosv_ss.c @@ -57,6 +57,15 @@ ss_ev(struct ovni_ethread *th, int ev) th->ss_event = ev; } +static int +ss_last_st(struct ovni_ethread *th) +{ + if(th->nss == 0) + return ST_NULL; + + return th->ss[th->nss - 1]; +} + /* --------------------------- pre ------------------------------- */ static void @@ -121,12 +130,32 @@ emit_thread_state(struct ovni_emu *emu, struct ovni_ethread *th, int type, int st) { int row; - + row = th->gindex + 1; prv_ev_thread(emu, row, type, st); } +static void +emit_thread_event(struct ovni_emu *emu, struct ovni_ethread *th, + int type, int st) +{ + int64_t t0, t1; + int row; + int prev_st; + + row = th->gindex + 1; + + t0 = emu->delta_time - 1; + t1 = emu->delta_time; + + prev_st = ss_last_st(th); + + /* Fake event using 1 nanosecond in the past */ + prv_ev_thread_raw(emu, row, t0, type, st); + prv_ev_thread_raw(emu, row, t1, type, prev_st); +} + void hook_emit_nosv_ss(struct ovni_emu *emu) { @@ -134,23 +163,16 @@ hook_emit_nosv_ss(struct ovni_emu *emu) th = emu->cur_thread; -// /* Only emit a state if needed */ -// if(th->ss_event != EV_NULL) -// { -// emit_thread_state(emu, th, PTT_SUBSYSTEM, -// th->ss_event); -// } -// else + /* Only emit a state if needed */ + if(th->ss_event != EV_NULL) + { + emit_thread_event(emu, th, PTT_SUBSYSTEM, + th->ss_event); - if(th->nss > 0) - { - emit_thread_state(emu, th, PTT_SUBSYSTEM, - th->ss[th->nss - 1]); - } - else - { - emit_thread_state(emu, th, PTT_SUBSYSTEM, ST_NULL); + return; } + + emit_thread_state(emu, th, PTT_SUBSYSTEM, ss_last_st(th)); } /* --------------------------- post ------------------------------- */ diff --git a/pcf.c b/pcf.c index 21d0512..536d561 100644 --- a/pcf.c +++ b/pcf.c @@ -119,6 +119,9 @@ struct event_value thread_ss_values[] = { { ST_SCHED_HUNGRY, "Scheduler: Hungry" }, { ST_SCHED_SERVING, "Scheduler: Serving" }, { ST_SCHED_SUBMITTING, "Scheduler: Submitting" }, + { EV_SCHED_SEND, "EV Scheduler: Send task" }, + { EV_SCHED_RECV, "EV Scheduler: Recv task" }, + { EV_SCHED_SELF, "EV Scheduler: Self-assign task" }, { -1, NULL }, };