Removed the extra info struct in the cpu_ent union and made said union a struct instead. Same as r1137 in NewOS.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2006-04-29 22:38:19 +00:00
parent 2a03240eb1
commit 17fee3eab7
6 changed files with 32 additions and 34 deletions

View File

@ -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)));

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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;
}

View File

@ -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(" -");