Use local bursts per thread

This commit is contained in:
Rodrigo Arias 2021-10-11 12:42:37 +02:00
parent 1d4796521b
commit 019668ac53
2 changed files with 19 additions and 14 deletions

12
emu.h
View File

@ -166,6 +166,8 @@ const static int chan_to_prvtype[CHAN_MAX][3] = {
// PTT_TASK_APP_ID = 65, // PTT_TASK_APP_ID = 65,
//}; //};
#define MAX_BURSTS 100
/* State of each emulated thread */ /* State of each emulated thread */
struct ovni_ethread { struct ovni_ethread {
/* Emulated thread tid */ /* Emulated thread tid */
@ -196,6 +198,10 @@ struct ovni_ethread {
/* Channels are used to output the emulator state in PRV */ /* Channels are used to output the emulator state in PRV */
struct ovni_chan chan[CHAN_MAX]; struct ovni_chan chan[CHAN_MAX];
/* Burst times */
int nbursts;
int64_t burst_time[MAX_BURSTS];
}; };
/* State of each emulated process */ /* State of each emulated process */
@ -325,8 +331,6 @@ struct ovni_stream {
int64_t clock_offset; int64_t clock_offset;
}; };
#define MAX_BURSTS 100
struct ovni_emu { struct ovni_emu {
struct ovni_trace trace; struct ovni_trace trace;
@ -359,10 +363,6 @@ struct ovni_emu {
int total_nthreads; int total_nthreads;
int total_proc; int total_proc;
int total_ncpus; int total_ncpus;
/* Burst times */
int nbursts;
int64_t burst_time[MAX_BURSTS];
}; };
/* Emulator function declaration */ /* Emulator function declaration */

View File

@ -518,22 +518,27 @@ pre_affinity(struct ovni_emu *emu)
void void
pre_burst(struct ovni_emu *emu) pre_burst(struct ovni_emu *emu)
{ {
struct ovni_ethread *th;
int64_t dt; int64_t dt;
if(emu->nbursts >= MAX_BURSTS)
th = emu->cur_thread;
if(th->nbursts >= MAX_BURSTS)
{ {
err("too many bursts\n"); err("too many bursts: ignored\n");
abort(); return;
} }
emu->burst_time[emu->nbursts] = emu->delta_time; th->burst_time[th->nbursts] = emu->delta_time;
if(emu->nbursts > 0) if(th->nbursts > 0)
{ {
dt = emu->burst_time[emu->nbursts] - dt = th->burst_time[th->nbursts] -
emu->burst_time[emu->nbursts - 1]; th->burst_time[th->nbursts - 1];
err("burst delta time %ld ns\n", dt); err("burst delta time %ld ns\n", dt);
} }
emu->nbursts++;
th->nbursts++;
} }
void void