- else
- halt_all_cpus(!(options & HOST_REBOOT_HALT));
-
- return (KERN_SUCCESS);
-}
-
-/*
- * processor_request_action:
- *
- * Common internals of processor_assign and processor_shutdown.
- * If new_pset is null, this is a shutdown, else it's an assign
- * and caller must donate a reference.
- * For assign operations, it returns an old pset that must be deallocated
- * if it's not NULL.
- * For shutdown operations, it always returns PROCESSOR_SET_NULL.
- */
-processor_set_t
-processor_request_action(
- processor_t processor,
- processor_set_t new_pset)
-{
- processor_set_t pset, old_pset;
-
- /*
- * Processor must be in a processor set. Must lock its idle lock to
- * get at processor state.
- */
- pset = processor->processor_set;
- simple_lock(&pset->sched_lock);
-
- /*
- * If the processor is dispatching, let it finish - it will set its
- * state to running very soon.
- */
- while (*(volatile int *)&processor->state == PROCESSOR_DISPATCHING) {
- simple_unlock(&pset->sched_lock);
-
- simple_lock(&pset->sched_lock);
- }
-
- assert( processor->state == PROCESSOR_IDLE ||
- processor->state == PROCESSOR_RUNNING ||
- processor->state == PROCESSOR_ASSIGN );
-
- /*
- * Now lock the action queue and do the dirty work.
- */
- simple_lock(&processor_action_lock);
-
- if (processor->state == PROCESSOR_IDLE) {
- remqueue(&pset->idle_queue, (queue_entry_t)processor);
- pset->idle_count--;
- }
- else
- if (processor->state == PROCESSOR_RUNNING)
- remqueue(&pset->active_queue, (queue_entry_t)processor);
-
- if (processor->state != PROCESSOR_ASSIGN)
- enqueue_tail(&processor_action_queue, (queue_entry_t)processor);
-
- /*
- * And ask the action_thread to do the work.
- */
- if (new_pset != PROCESSOR_SET_NULL) {
- processor->state = PROCESSOR_ASSIGN;
- old_pset = processor->processor_set_next;
- processor->processor_set_next = new_pset;
- }
- else {
- processor->state = PROCESSOR_SHUTDOWN;
- old_pset = PROCESSOR_SET_NULL;
- }
-
- simple_unlock(&pset->sched_lock);
-
- if (processor_action_active) {
- simple_unlock(&processor_action_lock);
-
- return (old_pset);
- }
-
- processor_action_active = TRUE;
- simple_unlock(&processor_action_lock);