FreeBSD/sys/kern/kern_shutdown.c
/*
 * Shutdown the system cleanly to prepare for reboot, halt, or power off.
 */
Shutdown the system cleanly to prepare for reboot, halt, or power off.
Shutdown the system cleanly to prepare for reboot halt or power off .
void
kern_reboot(int howto)
{
	static int once = 0;
#if defined(SMP)
	if (!SCHEDULER_STOPPED()) {
		thread_lock(curthread);
		sched_bind(curthread, 0);
		thread_unlock(curthread);
		KASSERT(PCPU_GET(cpuid) == 0, ("boot: not running on cpu 0"));
	}
#endif
	rebooting = 1;
	kdb_active = 0;
	EVENTHANDLER_INVOKE(shutdown_pre_sync, howto);
	if (!cold && (howto & RB_NOSYNC) == 0 && once == 0) {
		once = 1;
		bufshutdown(show_busybufs);
	}
	print_uptime();
	cngrab();
	EVENTHANDLER_INVOKE(shutdown_post_sync, howto);
	if ((howto & (RB_HALT|RB_DUMP)) == RB_DUMP && !cold && !dumping) 
		doadump(TRUE);
	EVENTHANDLER_INVOKE(shutdown_final, howto);
	for(;;) ;	
}
void kern_reboot ( int howto ) { static int once = 0 ; #if defined ( SMP ) if ( ! SCHEDULER_STOPPED ( ) ) { thread_lock ( curthread ) ; sched_bind ( curthread , 0 ) ; thread_unlock ( curthread ) ; KASSERT ( PCPU_GET ( cpuid ) == 0 , ( " " ) ) ; } #endif rebooting = 1 ; kdb_active = 0 ; EVENTHANDLER_INVOKE ( shutdown_pre_sync , howto ) ; if ( ! cold && ( howto & RB_NOSYNC ) == 0 && once == 0 ) { once = 1 ; bufshutdown ( show_busybufs ) ; } print_uptime ( ) ; cngrab ( ) ; EVENTHANDLER_INVOKE ( shutdown_post_sync , howto ) ; if ( ( howto & ( RB_HALT | RB_DUMP ) ) == RB_DUMP && ! cold && ! dumping ) doadump ( TRUE ) ; EVENTHANDLER_INVOKE ( shutdown_final , howto ) ; for ( ; ; ) ; }
Shutdown the system cleanly to prepare for reboot, halt, or power off.
Shutdown the system cleanly to prepare for reboot halt or power off .
/*
	 * Bind us to CPU 0 so that all shutdown code runs there.  Some
	 * systems don't shutdown properly (i.e., ACPI power off) if we
	 * run on another processor.
	 */ /* We're in the process of rebooting. */ /* We are out of the debugger now. */ /*
	 * Do any callouts that should be done BEFORE syncing the filesystems.
	 */ /* 
	 * Now sync filesystems
	 */ /*
	 * Ok, now do things that assume all filesystem activity has
	 * been completed.
	 */ /* Now that we're going to really halt the system... */ /* safety against shutdown_reset not working */ /* NOTREACHED */