kernel: Allow scheduler initialization to fail

This commit is contained in:
Pawel Dziepak 2013-10-05 20:45:07 +02:00
parent 9ad558f01c
commit 6d7e291233
7 changed files with 27 additions and 9 deletions

View File

@ -67,19 +67,23 @@ scheduler_init(void)
dprintf("scheduler_init: found %" B_PRId32 " logical cpu%s\n", cpuCount,
cpuCount != 1 ? "s" : "");
status_t result;
if (cpuCount > 1) {
#if 0
dprintf("scheduler_init: using affine scheduler\n");
scheduler_affine_init();
result = scheduler_affine_init();
#else
dprintf("scheduler_init: using simple SMP scheduler\n");
scheduler_simple_smp_init();
result = scheduler_simple_smp_init();
#endif
} else {
dprintf("scheduler_init: using simple scheduler\n");
scheduler_simple_init();
result = scheduler_simple_init();
}
if (result != B_OK)
panic("scheduler_init: failed to initialize scheduler\n");
// Disable rescheduling until the basic kernel initialization is done and
// CPUs are ready to enable interrupts.
sRescheduleFunction = gScheduler->reschedule;

View File

@ -556,7 +556,7 @@ static scheduler_ops kAffineOps = {
// #pragma mark -
void
status_t
scheduler_affine_init()
{
gScheduler = &kAffineOps;
@ -564,4 +564,6 @@ scheduler_affine_init()
memset(sRunQueueSize, 0, sizeof(sRunQueueSize));
add_debugger_command_etc("run_queue", &dump_run_queue,
"List threads in run queue", "\nLists threads in run queue", 0);
return B_OK;
}

View File

@ -7,7 +7,7 @@
#define KERNEL_SCHEDULER_AFFINE_H
void scheduler_affine_init();
status_t scheduler_affine_init();
#endif // KERNEL_SCHEDULER_AFFINE_H

View File

@ -328,13 +328,23 @@ static scheduler_ops kSimpleOps = {
// #pragma mark -
void
status_t
scheduler_simple_init()
{
sRunQueue = new(std::nothrow) RunQueue<Thread, THREAD_MAX_SET_PRIORITY>;
if (sRunQueue == NULL)
return B_NO_MEMORY;
status_t result = sRunQueue->GetInitStatus();
if (result != B_OK) {
delete sRunQueue;
return result;
}
gScheduler = &kSimpleOps;
add_debugger_command_etc("run_queue", &dump_run_queue,
"List threads in run queue", "\nLists threads in run queue", 0);
return B_OK;
}

View File

@ -6,7 +6,7 @@
#define KERNEL_SCHEDULER_SIMPLE_H
void scheduler_simple_init();
status_t scheduler_simple_init();
#endif // KERNEL_SCHEDULER_SIMPLE_H

View File

@ -471,7 +471,7 @@ static scheduler_ops kSimpleSMPOps = {
// #pragma mark -
void
status_t
scheduler_simple_smp_init()
{
sCPUCount = smp_get_num_cpus();
@ -480,4 +480,6 @@ scheduler_simple_smp_init()
add_debugger_command_etc("run_queue", &dump_run_queue,
"List threads in run queue", "\nLists threads in run queue", 0);
return B_OK;
}

View File

@ -6,7 +6,7 @@
#define KERNEL_SCHEDULER_SIMPLE_SMP_H
void scheduler_simple_smp_init();
status_t scheduler_simple_smp_init();
#endif // KERNEL_SCHEDULER_SIMPLE_SMP_H