From 019668ac536e93200ad3fbb613426d79450751d2 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 11 Oct 2021 12:42:37 +0200 Subject: [PATCH] Use local bursts per thread --- emu.h | 12 ++++++------ emu_ovni.c | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/emu.h b/emu.h index ab6f2f7..194f5ec 100644 --- a/emu.h +++ b/emu.h @@ -166,6 +166,8 @@ const static int chan_to_prvtype[CHAN_MAX][3] = { // PTT_TASK_APP_ID = 65, //}; +#define MAX_BURSTS 100 + /* State of each emulated thread */ struct ovni_ethread { /* Emulated thread tid */ @@ -196,6 +198,10 @@ struct ovni_ethread { /* Channels are used to output the emulator state in PRV */ struct ovni_chan chan[CHAN_MAX]; + + /* Burst times */ + int nbursts; + int64_t burst_time[MAX_BURSTS]; }; /* State of each emulated process */ @@ -325,8 +331,6 @@ struct ovni_stream { int64_t clock_offset; }; -#define MAX_BURSTS 100 - struct ovni_emu { struct ovni_trace trace; @@ -359,10 +363,6 @@ struct ovni_emu { int total_nthreads; int total_proc; int total_ncpus; - - /* Burst times */ - int nbursts; - int64_t burst_time[MAX_BURSTS]; }; /* Emulator function declaration */ diff --git a/emu_ovni.c b/emu_ovni.c index 3e07b1e..3159665 100644 --- a/emu_ovni.c +++ b/emu_ovni.c @@ -518,22 +518,27 @@ pre_affinity(struct ovni_emu *emu) void pre_burst(struct ovni_emu *emu) { + struct ovni_ethread *th; int64_t dt; - if(emu->nbursts >= MAX_BURSTS) + + th = emu->cur_thread; + + if(th->nbursts >= MAX_BURSTS) { - err("too many bursts\n"); - abort(); + err("too many bursts: ignored\n"); + return; } - emu->burst_time[emu->nbursts] = emu->delta_time; - if(emu->nbursts > 0) + th->burst_time[th->nbursts] = emu->delta_time; + if(th->nbursts > 0) { - dt = emu->burst_time[emu->nbursts] - - emu->burst_time[emu->nbursts - 1]; + dt = th->burst_time[th->nbursts] - + th->burst_time[th->nbursts - 1]; err("burst delta time %ld ns\n", dt); } - emu->nbursts++; + + th->nbursts++; } void