- if (processor->next_thread == THREAD_NULL) {
- thread_t thread;
- extern void start_cpu_thread(void);
-
- thread = kernel_thread_with_priority(
- kernel_task, MAXPRI_KERNEL,
- start_cpu_thread, TRUE, FALSE);
+ /*
+ * Create the idle processor thread.
+ */
+ if (processor->idle_thread == THREAD_NULL) {
+ result = idle_thread_create(processor);
+ if (result != KERN_SUCCESS) {
+ s = splsched();
+ processor_lock(processor);
+ processor->state = PROCESSOR_OFF_LINE;
+ processor_unlock(processor);
+ splx(s);
+
+ return (result);
+ }
+ }
+
+ /*
+ * If there is no active thread, the processor
+ * has never been started. Create a dedicated
+ * start up thread.
+ */
+ if ( processor->active_thread == THREAD_NULL &&
+ processor->next_thread == THREAD_NULL ) {
+ result = kernel_thread_create((thread_continue_t)processor_start_thread, NULL, MAXPRI_KERNEL, &thread);
+ if (result != KERN_SUCCESS) {
+ s = splsched();
+ processor_lock(processor);
+ processor->state = PROCESSOR_OFF_LINE;
+ processor_unlock(processor);
+ splx(s);
+
+ return (result);
+ }