Avoid TID collisions searching only in cur_proc

This commit is contained in:
Rodrigo Arias 2021-09-20 15:42:45 +02:00
parent 67a9b8f319
commit e80bcdd224
3 changed files with 9 additions and 25 deletions

26
emu.c
View File

@ -221,35 +221,19 @@ emulate(struct ovni_emu *emu)
}
struct ovni_ethread *
emu_get_thread(struct ovni_emu *emu, int tid)
emu_get_thread(struct ovni_eproc *proc, int tid)
{
int i, j, k;
struct ovni_loom *loom;
struct ovni_eproc *proc;
int i;
struct ovni_ethread *thread;
for(i=0; i<emu->trace.nlooms; i++)
for(i=0; i<proc->nthreads; i++)
{
loom = &emu->trace.loom[i];
for(j=0; j<loom->nprocs; j++)
{
proc = &loom->proc[j];
for(k=0; k<proc->nthreads; k++)
{
thread = &proc->thread[k];
thread = &proc->thread[i];
if(thread->tid == tid)
{
/* Only same process threads can
* change the affinity to each
* others */
assert(emu->cur_proc == proc);
return thread;
}
}
}
}
return thread;
return NULL;
}
static void

2
emu.h
View File

@ -220,7 +220,7 @@ void hook_post_nosv(struct ovni_emu *emu);
struct ovni_cpu *emu_get_cpu(struct ovni_loom *loom, int cpuid);
struct ovni_ethread *emu_get_thread(struct ovni_emu *emu, int tid);
struct ovni_ethread *emu_get_thread(struct ovni_eproc *proc, int tid);
void emu_emit_prv(struct ovni_emu *emu, int type, int val);

View File

@ -210,7 +210,7 @@ ev_affinity_remote(struct ovni_emu *emu)
cpuid = emu->cur_ev->payload.i32[0];
tid = emu->cur_ev->payload.i32[1];
thread = emu_get_thread(emu, tid);
thread = emu_get_thread(emu->cur_proc, tid);
assert(thread);