eclair: make idle threads visible

This commit is contained in:
Balazs Gerofi
2016-07-22 18:06:11 +09:00
parent 4c8f583c0c
commit d0539a9cac
2 changed files with 61 additions and 0 deletions

View File

@ -55,6 +55,7 @@ uintptr_t debug_constants[] = {
offsetof(struct cpu_local_var, current), offsetof(struct cpu_local_var, current),
offsetof(struct cpu_local_var, runq), offsetof(struct cpu_local_var, runq),
offsetof(struct cpu_local_var, status), offsetof(struct cpu_local_var, status),
offsetof(struct cpu_local_var, idle),
offsetof(struct thread, ctx), offsetof(struct thread, ctx),
offsetof(struct thread, sched_list), offsetof(struct thread, sched_list),
offsetof(struct thread, proc), offsetof(struct thread, proc),

View File

@ -167,6 +167,7 @@ enum {
CURRENT_OFFSET, CURRENT_OFFSET,
RUNQ_OFFSET, RUNQ_OFFSET,
CPU_STATUS_OFFSET, CPU_STATUS_OFFSET,
IDLE_THREAD_OFFSET,
/* process */ /* process */
CTX_OFFSET, CTX_OFFSET,
@ -204,6 +205,7 @@ static int setup_constants(void) {
printf("CURRENT_OFFSET: %ld\n", K(CURRENT_OFFSET)); printf("CURRENT_OFFSET: %ld\n", K(CURRENT_OFFSET));
printf("RUNQ_OFFSET: %ld\n", K(RUNQ_OFFSET)); printf("RUNQ_OFFSET: %ld\n", K(RUNQ_OFFSET));
printf("CPU_STATUS_OFFSET: %ld\n", K(CPU_STATUS_OFFSET)); printf("CPU_STATUS_OFFSET: %ld\n", K(CPU_STATUS_OFFSET));
printf("IDLE_THREAD_OFFSET: %ld\n", K(IDLE_THREAD_OFFSET));
printf("CTX_OFFSET: %ld\n", K(CTX_OFFSET)); printf("CTX_OFFSET: %ld\n", K(CTX_OFFSET));
printf("SCHED_LIST_OFFSET: %ld\n", K(SCHED_LIST_OFFSET)); printf("SCHED_LIST_OFFSET: %ld\n", K(SCHED_LIST_OFFSET));
printf("PROC_OFFSET: %ld\n", K(PROC_OFFSET)); printf("PROC_OFFSET: %ld\n", K(PROC_OFFSET));
@ -251,6 +253,64 @@ static int setup_threads(void) {
ihk_mc_switch_context = lookup_symbol("ihk_mc_switch_context"); ihk_mc_switch_context = lookup_symbol("ihk_mc_switch_context");
if (0) printf("ihk_mc_switch_context: %lx\n", ihk_mc_switch_context); if (0) printf("ihk_mc_switch_context: %lx\n", ihk_mc_switch_context);
/* Set up idle threads first */
for (cpu = 0; cpu < num_processors; ++cpu) {
uintptr_t v;
uintptr_t thread;
uintptr_t proc;
int pid;
int tid;
struct thread_info *ti;
int status;
v = clv + (cpu * K(CPU_LOCAL_VAR_SIZE));
ti = malloc(sizeof(*ti));
if (!ti) {
perror("malloc");
return 1;
}
thread = v+K(IDLE_THREAD_OFFSET);
error = read_64(thread+K(PROC_OFFSET), &proc);
if (error) {
perror("proc");
return 1;
}
error = read_32(thread+K(STATUS_OFFSET), &status);
if (error) {
perror("status");
return 1;
}
error = read_32(proc+K(PID_OFFSET), &pid);
if (error) {
perror("pid");
return 1;
}
error = read_32(thread+K(TID_OFFSET), &tid);
if (error) {
perror("tid");
return 1;
}
ti->next = NULL;
ti->status = status;
ti->pid = pid;
ti->tid = tid;
ti->cpu = cpu;
ti->lcpu = cpu;
ti->process = thread;
ti->clv = v;
ti->x86_clv = locals + locals_span*cpu;
*titailp = ti;
titailp = &ti->next;
}
for (cpu = 0; cpu < num_processors; ++cpu) { for (cpu = 0; cpu < num_processors; ++cpu) {
uintptr_t v; uintptr_t v;
uintptr_t head; uintptr_t head;