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:
@@ -16,21 +16,19 @@
|
|||||||
|
|
||||||
/* CPU local data structure */
|
/* CPU local data structure */
|
||||||
|
|
||||||
typedef union cpu_ent {
|
typedef struct cpu_ent {
|
||||||
struct {
|
int cpu_num;
|
||||||
int cpu_num;
|
|
||||||
|
|
||||||
// thread.c: used to force a reschedule at quantum expiration time
|
// thread.c: used to force a reschedule at quantum expiration time
|
||||||
int preempted;
|
int preempted;
|
||||||
timer quantum_timer;
|
timer quantum_timer;
|
||||||
|
|
||||||
// keeping track of CPU activity
|
// keeping track of CPU activity
|
||||||
bigtime_t active_time;
|
bigtime_t active_time;
|
||||||
bigtime_t last_kernel_time;
|
bigtime_t last_kernel_time;
|
||||||
bigtime_t last_user_time;
|
bigtime_t last_user_time;
|
||||||
|
|
||||||
bool disabled;
|
bool disabled;
|
||||||
} info;
|
|
||||||
} cpu_ent __attribute__((aligned(64)));
|
} cpu_ent __attribute__((aligned(64)));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ struct thread {
|
|||||||
int32 next_priority;
|
int32 next_priority;
|
||||||
int32 state;
|
int32 state;
|
||||||
int32 next_state;
|
int32 next_state;
|
||||||
union cpu_ent *cpu;
|
struct cpu_ent *cpu;
|
||||||
|
|
||||||
sigset_t sig_pending;
|
sigset_t sig_pending;
|
||||||
sigset_t sig_block_mask;
|
sigset_t sig_block_mask;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ cpu_init(kernel_args *args)
|
|||||||
|
|
||||||
memset(gCPU, 0, sizeof(gCPU));
|
memset(gCPU, 0, sizeof(gCPU));
|
||||||
for (i = 0; i < MAX_BOOT_CPUS; i++) {
|
for (i = 0; i < MAX_BOOT_CPUS; i++) {
|
||||||
gCPU[i].info.cpu_num = i;
|
gCPU[i].cpu_num = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return arch_cpu_init(args);
|
return arch_cpu_init(args);
|
||||||
@@ -73,7 +73,7 @@ cpu_get_active_time(int32 cpu)
|
|||||||
state = disable_interrupts();
|
state = disable_interrupts();
|
||||||
GRAB_THREAD_LOCK();
|
GRAB_THREAD_LOCK();
|
||||||
|
|
||||||
activeTime = gCPU[cpu].info.active_time;
|
activeTime = gCPU[cpu].active_time;
|
||||||
|
|
||||||
RELEASE_THREAD_LOCK();
|
RELEASE_THREAD_LOCK();
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
@@ -105,7 +105,7 @@ _user_cpu_enabled(int32 cpu)
|
|||||||
if (cpu < 0 || cpu >= smp_get_num_cpus())
|
if (cpu < 0 || cpu >= smp_get_num_cpus())
|
||||||
return B_BAD_VALUE;
|
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) {
|
if (!enabled) {
|
||||||
// check if this is the last CPU to be disabled
|
// check if this is the last CPU to be disabled
|
||||||
for (i = 0, count = 0; i < smp_get_num_cpus(); i++) {
|
for (i = 0, count = 0; i < smp_get_num_cpus(); i++) {
|
||||||
if (!gCPU[i].info.disabled)
|
if (!gCPU[i].disabled)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ _user_set_cpu_enabled(int32 cpu, bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
gCPU[cpu].info.disabled = !enabled;
|
gCPU[cpu].disabled = !enabled;
|
||||||
|
|
||||||
release_spinlock(&sSetCpuLock);
|
release_spinlock(&sSetCpuLock);
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ reschedule_event(timer *unused)
|
|||||||
{
|
{
|
||||||
// this function is called as a result of the timer event set by the scheduler
|
// this function is called as a result of the timer event set by the scheduler
|
||||||
// returning this causes a reschedule on the timer event
|
// 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;
|
return B_INVOKE_SCHEDULER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ scheduler_reschedule(void)
|
|||||||
nextThread = sRunQueue;
|
nextThread = sRunQueue;
|
||||||
prevThread = NULL;
|
prevThread = NULL;
|
||||||
|
|
||||||
if (oldThread->cpu->info.disabled) {
|
if (oldThread->cpu->disabled) {
|
||||||
// just select an idle thread
|
// just select an idle thread
|
||||||
while (nextThread && nextThread->priority > B_IDLE_PRIORITY) {
|
while (nextThread && nextThread->priority > B_IDLE_PRIORITY) {
|
||||||
prevThread = nextThread;
|
prevThread = nextThread;
|
||||||
@@ -225,24 +225,24 @@ scheduler_reschedule(void)
|
|||||||
|
|
||||||
// track CPU activity
|
// track CPU activity
|
||||||
if (!thread_is_idle_thread(oldThread)) {
|
if (!thread_is_idle_thread(oldThread)) {
|
||||||
oldThread->cpu->info.active_time +=
|
oldThread->cpu->active_time +=
|
||||||
(oldThread->kernel_time - oldThread->cpu->info.last_kernel_time)
|
(oldThread->kernel_time - oldThread->cpu->last_kernel_time)
|
||||||
+ (oldThread->user_time - oldThread->cpu->info.last_user_time);
|
+ (oldThread->user_time - oldThread->cpu->last_user_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thread_is_idle_thread(nextThread)) {
|
if (!thread_is_idle_thread(nextThread)) {
|
||||||
oldThread->cpu->info.last_kernel_time = nextThread->kernel_time;
|
oldThread->cpu->last_kernel_time = nextThread->kernel_time;
|
||||||
oldThread->cpu->info.last_user_time = nextThread->user_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!
|
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)
|
if (!oldThread->cpu->preempted)
|
||||||
_local_timer_cancel_event(oldThread->cpu->info.cpu_num, quantumTimer);
|
_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);
|
add_timer(quantumTimer, &reschedule_event, quantum, B_ONE_SHOT_RELATIVE_TIMER);
|
||||||
|
|
||||||
if (nextThread != oldThread)
|
if (nextThread != oldThread)
|
||||||
|
|||||||
@@ -653,9 +653,9 @@ smp_get_current_cpu(void)
|
|||||||
{
|
{
|
||||||
struct thread *thread = thread_get_current_thread();
|
struct thread *thread = thread_get_current_thread();
|
||||||
if (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
|
// for the boot process
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ _dump_thread_info(struct thread *thread)
|
|||||||
kprintf("next_state: %s\n", state_to_text(thread, thread->next_state));
|
kprintf("next_state: %s\n", state_to_text(thread, thread->next_state));
|
||||||
kprintf("cpu: %p ", thread->cpu);
|
kprintf("cpu: %p ", thread->cpu);
|
||||||
if (thread->cpu)
|
if (thread->cpu)
|
||||||
kprintf("(%d)\n", thread->cpu->info.cpu_num);
|
kprintf("(%d)\n", thread->cpu->cpu_num);
|
||||||
else
|
else
|
||||||
kprintf("\n");
|
kprintf("\n");
|
||||||
kprintf("sig_pending: 0x%lx\n", thread->sig_pending);
|
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?
|
// on which CPU does it run?
|
||||||
if (thread->cpu)
|
if (thread->cpu)
|
||||||
kprintf("%2d", thread->cpu->info.cpu_num);
|
kprintf("%2d", thread->cpu->cpu_num);
|
||||||
else
|
else
|
||||||
kprintf(" -");
|
kprintf(" -");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user