Ensure the thread is ready before adding cpus

This commit is contained in:
Rodrigo Arias 2024-09-10 11:45:24 +02:00
parent 6a54f19b76
commit 6a595fff0b
2 changed files with 5 additions and 4 deletions

View File

@ -188,8 +188,8 @@ ovni_add_cpu(int index, int phyid)
if (!rproc.ready) if (!rproc.ready)
die("process not yet initialized"); die("process not yet initialized");
if (rproc.meta == NULL) if (!rthread.ready)
die("metadata not initialized"); die("thread not yet initialized");
struct ovni_rcpu *cpu = malloc(sizeof(*cpu)); struct ovni_rcpu *cpu = malloc(sizeof(*cpu));
if (cpu == NULL) if (cpu == NULL)

View File

@ -27,10 +27,11 @@ main(void)
int app = rank / N; int app = rank / N;
char loom[128]; char loom[128];
if (snprintf(loom, 128, "loom.%04d", app) >= 128) if (snprintf(loom, 128, "node0.%04d", app) >= 128)
die("snprintf failed"); die("snprintf failed");
ovni_proc_init(1 + app, loom, getpid()); ovni_proc_init(1 + app, loom, getpid());
ovni_thread_init(get_tid());
ovni_proc_set_rank(rank, nranks); ovni_proc_set_rank(rank, nranks);
/* Leader of the segment, must emit CPUs */ /* Leader of the segment, must emit CPUs */
@ -39,13 +40,13 @@ main(void)
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
cpus[i] = app * N + i; cpus[i] = app * N + i;
ovni_add_cpu(i, cpus[i]); ovni_add_cpu(i, cpus[i]);
info("adding cpu %d to rank %d", i, rank);
} }
} }
int nlooms = nranks / N; int nlooms = nranks / N;
int lcpu = rank % N; int lcpu = rank % N;
ovni_thread_init(get_tid());
instr_require("ovni"); instr_require("ovni");
instr_nosv_init(); instr_nosv_init();
instr_thread_execute(lcpu, -1, 0); instr_thread_execute(lcpu, -1, 0);