Second (or third) try at getting the timers ordered by priority, in
r33218 I had ordered the timers in the wrong order. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33225 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ca7ba3eb23
commit
7ddaf32ecc
@ -61,7 +61,7 @@ arch_timer_clear_hardware_timer(void)
|
||||
sTimer->clear_hardware_timer();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
static void
|
||||
sort_timers(timer_info *timers[], int numTimers)
|
||||
{
|
||||
@ -72,53 +72,39 @@ sort_timers(timer_info *timers[], int numTimers)
|
||||
|
||||
for (size = numTimers; size > 1; size--) {
|
||||
for (i = 0; i < size; i++) {
|
||||
if (timers[i]->get_priority() > timers[max]->get_priority())
|
||||
if (timers[i]->get_priority() < timers[max]->get_priority())
|
||||
max = i;
|
||||
}
|
||||
tempPtr = timers[max];
|
||||
timers[max] = timers[size - 1];
|
||||
timers[size - 1] = tempPtr;
|
||||
}
|
||||
#if 0
|
||||
for (i = 0; i < numTimers; i++) {
|
||||
dprintf("timer[%d]: prio %d\n", i, timers[i]->get_priority());
|
||||
}
|
||||
#endif
|
||||
|
||||
dprintf("arch_init_timer:timers found:\n");
|
||||
for (i = 0; i < numTimers; i++)
|
||||
dprintf(" %s: priority %d\n", timers[i]->name, timers[i]->get_priority());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
arch_init_timer(kernel_args *args)
|
||||
{
|
||||
int i = 0;
|
||||
int bestPriority = -1;
|
||||
timer_info *timer = NULL;
|
||||
cpu_status state;
|
||||
|
||||
//sort_timers(sTimers, (sizeof(sTimers) / sizeof(sTimers[0])) - 1);
|
||||
// Sort timers by priority
|
||||
sort_timers(sTimers, (sizeof(sTimers) / sizeof(sTimers[0])) - 1);
|
||||
|
||||
state = disable_interrupts();
|
||||
|
||||
for (i = 0; (timer = sTimers[i]) != NULL; i++) {
|
||||
int priority = timer->get_priority();
|
||||
|
||||
if (priority < bestPriority) {
|
||||
TRACE(("arch_init_timer: Skipping %s because there is a higher priority timer (%s) initialized.\n", timer->name, sTimer->name));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (timer->init(args) != B_OK) {
|
||||
TRACE(("arch_init_timer: %s failed init. Skipping.\n", timer->name));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (priority > bestPriority) {
|
||||
bestPriority = priority;
|
||||
sTimer = timer;
|
||||
TRACE(("arch_init_timer: %s is now best timer module with prio %d.\n", timer->name, bestPriority));
|
||||
}
|
||||
if (timer->init(args) == B_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
sTimer = timer;
|
||||
|
||||
if (sTimer != NULL) {
|
||||
dprintf("arch_init_timer: using %s timer.\n", sTimer->name);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user