Emit sched fake events as well

This commit is contained in:
Rodrigo Arias 2021-09-23 12:41:43 +02:00 committed by Rodrigo Arias Mallo
parent 9b39e4d69e
commit b60c6da764
4 changed files with 47 additions and 20 deletions

1
emu.c
View File

@ -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;

View File

@ -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);
}

View File

@ -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
@ -127,6 +136,26 @@ emit_thread_state(struct ovni_emu *emu, struct ovni_ethread *th,
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 ------------------------------- */

3
pcf.c
View File

@ -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 },
};