diff --git a/headers/private/kernel/cpu.h b/headers/private/kernel/cpu.h index 19cd41e5a2..4393872542 100644 --- a/headers/private/kernel/cpu.h +++ b/headers/private/kernel/cpu.h @@ -16,21 +16,19 @@ /* CPU local data structure */ -typedef union cpu_ent { - struct { - int cpu_num; +typedef struct cpu_ent { + int cpu_num; - // thread.c: used to force a reschedule at quantum expiration time - int preempted; - timer quantum_timer; + // thread.c: used to force a reschedule at quantum expiration time + int preempted; + timer quantum_timer; - // keeping track of CPU activity - bigtime_t active_time; - bigtime_t last_kernel_time; - bigtime_t last_user_time; + // keeping track of CPU activity + bigtime_t active_time; + bigtime_t last_kernel_time; + bigtime_t last_user_time; - bool disabled; - } info; + bool disabled; } cpu_ent __attribute__((aligned(64))); diff --git a/headers/private/kernel/thread_types.h b/headers/private/kernel/thread_types.h index b7dd401425..b4cfe45db1 100644 --- a/headers/private/kernel/thread_types.h +++ b/headers/private/kernel/thread_types.h @@ -138,7 +138,7 @@ struct thread { int32 next_priority; int32 state; int32 next_state; - union cpu_ent *cpu; + struct cpu_ent *cpu; sigset_t sig_pending; sigset_t sig_block_mask; diff --git a/src/system/kernel/cpu.c b/src/system/kernel/cpu.c index 1ec053eeba..66de2d625b 100644 --- a/src/system/kernel/cpu.c +++ b/src/system/kernel/cpu.c @@ -30,7 +30,7 @@ cpu_init(kernel_args *args) memset(gCPU, 0, sizeof(gCPU)); for (i = 0; i < MAX_BOOT_CPUS; i++) { - gCPU[i].info.cpu_num = i; + gCPU[i].cpu_num = i; } return arch_cpu_init(args); @@ -73,7 +73,7 @@ cpu_get_active_time(int32 cpu) state = disable_interrupts(); GRAB_THREAD_LOCK(); - activeTime = gCPU[cpu].info.active_time; + activeTime = gCPU[cpu].active_time; RELEASE_THREAD_LOCK(); restore_interrupts(state); @@ -105,7 +105,7 @@ _user_cpu_enabled(int32 cpu) if (cpu < 0 || cpu >= smp_get_num_cpus()) return B_BAD_VALUE; - return !gCPU[cpu].info.disabled; + return !gCPU[cpu].disabled; } @@ -128,7 +128,7 @@ _user_set_cpu_enabled(int32 cpu, bool enabled) if (!enabled) { // check if this is the last CPU to be disabled for (i = 0, count = 0; i < smp_get_num_cpus(); i++) { - if (!gCPU[i].info.disabled) + if (!gCPU[i].disabled) count++; } @@ -137,7 +137,7 @@ _user_set_cpu_enabled(int32 cpu, bool enabled) } if (status == B_OK) - gCPU[cpu].info.disabled = !enabled; + gCPU[cpu].disabled = !enabled; release_spinlock(&sSetCpuLock); restore_interrupts(state); diff --git a/src/system/kernel/scheduler.cpp b/src/system/kernel/scheduler.cpp index 5e3b21bc40..b4fbff6b44 100644 --- a/src/system/kernel/scheduler.cpp +++ b/src/system/kernel/scheduler.cpp @@ -140,7 +140,7 @@ reschedule_event(timer *unused) { // this function is called as a result of the timer event set by the scheduler // returning this causes a reschedule on the timer event - thread_get_current_thread()->cpu->info.preempted = 1; + thread_get_current_thread()->cpu->preempted = 1; return B_INVOKE_SCHEDULER; } @@ -180,7 +180,7 @@ scheduler_reschedule(void) nextThread = sRunQueue; prevThread = NULL; - if (oldThread->cpu->info.disabled) { + if (oldThread->cpu->disabled) { // just select an idle thread while (nextThread && nextThread->priority > B_IDLE_PRIORITY) { prevThread = nextThread; @@ -225,24 +225,24 @@ scheduler_reschedule(void) // track CPU activity if (!thread_is_idle_thread(oldThread)) { - oldThread->cpu->info.active_time += - (oldThread->kernel_time - oldThread->cpu->info.last_kernel_time) - + (oldThread->user_time - oldThread->cpu->info.last_user_time); + oldThread->cpu->active_time += + (oldThread->kernel_time - oldThread->cpu->last_kernel_time) + + (oldThread->user_time - oldThread->cpu->last_user_time); } if (!thread_is_idle_thread(nextThread)) { - oldThread->cpu->info.last_kernel_time = nextThread->kernel_time; - oldThread->cpu->info.last_user_time = nextThread->user_time; + oldThread->cpu->last_kernel_time = nextThread->kernel_time; + oldThread->cpu->last_user_time = nextThread->user_time; } - if (nextThread != oldThread || oldThread->cpu->info.preempted) { + if (nextThread != oldThread || oldThread->cpu->preempted) { bigtime_t quantum = 3000; // ToDo: calculate quantum! - timer *quantumTimer = &oldThread->cpu->info.quantum_timer; + timer *quantumTimer = &oldThread->cpu->quantum_timer; - if (!oldThread->cpu->info.preempted) - _local_timer_cancel_event(oldThread->cpu->info.cpu_num, quantumTimer); + if (!oldThread->cpu->preempted) + _local_timer_cancel_event(oldThread->cpu->cpu_num, quantumTimer); - oldThread->cpu->info.preempted = 0; + oldThread->cpu->preempted = 0; add_timer(quantumTimer, &reschedule_event, quantum, B_ONE_SHOT_RELATIVE_TIMER); if (nextThread != oldThread) diff --git a/src/system/kernel/smp.c b/src/system/kernel/smp.c index 736251e5c4..d4d1304bc5 100644 --- a/src/system/kernel/smp.c +++ b/src/system/kernel/smp.c @@ -653,9 +653,9 @@ smp_get_current_cpu(void) { struct thread *thread = thread_get_current_thread(); if (thread) - return thread->cpu->info.cpu_num; + return thread->cpu->cpu_num; - // this is not always correct during early boot, but it's okay for + // this is not always correct during early boot, but it's okay // for the boot process return 0; } diff --git a/src/system/kernel/thread.c b/src/system/kernel/thread.c index ee68543538..b905e27627 100644 --- a/src/system/kernel/thread.c +++ b/src/system/kernel/thread.c @@ -546,7 +546,7 @@ _dump_thread_info(struct thread *thread) kprintf("next_state: %s\n", state_to_text(thread, thread->next_state)); kprintf("cpu: %p ", thread->cpu); if (thread->cpu) - kprintf("(%d)\n", thread->cpu->info.cpu_num); + kprintf("(%d)\n", thread->cpu->cpu_num); else kprintf("\n"); kprintf("sig_pending: 0x%lx\n", thread->sig_pending); @@ -671,7 +671,7 @@ dump_thread_list(int argc, char **argv) // on which CPU does it run? if (thread->cpu) - kprintf("%2d", thread->cpu->info.cpu_num); + kprintf("%2d", thread->cpu->cpu_num); else kprintf(" -");