FreeBSD/sys/geom/sched/g_sched.c
/*
 * Module event called when a scheduling algorithm module is loaded or
 * unloaded.
 */
Module event called when a scheduling algorithm module is loaded or
unloaded.
Module event called when a scheduling algorithm module is loaded or unloaded .
int
g_gsched_modevent(module_t mod, int cmd, void *arg)
{
	struct g_gsched *gsp = arg;
	struct g_gsched_unregparm parm;
	int error;
	G_SCHED_DEBUG(0, "Modevent %d.", cmd);
	g_gsched_global_init();
	error = EOPNOTSUPP;
	switch (cmd) {
	case MOD_LOAD:
		error = g_gsched_register(gsp);
		G_SCHED_DEBUG(0, "Loaded module %s error %d.",
		    gsp->gs_name, error);
		if (error == 0)
			g_retaste(&g_sched_class);
		break;
	case MOD_UNLOAD:
		parm.gup_gsp = gsp;
		parm.gup_error = 0;
		error = g_waitfor_event(g_gsched_unregister,
		    &parm, M_WAITOK, NULL);
		if (error == 0)
			error = parm.gup_error;
		G_SCHED_DEBUG(0, "Unloaded module %s error %d.",
		    gsp->gs_name, error);
		break;
	}
	return (error);
}
int g_gsched_modevent ( module_t mod , int cmd , void * arg ) { struct g_gsched * gsp = arg ; struct g_gsched_unregparm parm ; int error ; G_SCHED_DEBUG ( 0 , " " , cmd ) ; g_gsched_global_init ( ) ; error = EOPNOTSUPP ; switch ( cmd ) { case MOD_LOAD : error = g_gsched_register ( gsp ) ; G_SCHED_DEBUG ( 0 , " " , gsp -> gs_name , error ) ; if ( error == 0 ) g_retaste ( & g_sched_class ) ; break ; case MOD_UNLOAD : parm . gup_gsp = gsp ; parm . gup_error = 0 ; error = g_waitfor_event ( g_gsched_unregister , & parm , M_WAITOK , NULL ) ; if ( error == 0 ) error = parm . gup_error ; G_SCHED_DEBUG ( 0 , " " , gsp -> gs_name , error ) ; break ; } return ( error ) ; }
Module event called when a scheduling algorithm module is loaded or
 unloaded.
Module event called when a scheduling algorithm module is loaded or unloaded .
/*
	 * If the module is loaded at boot, the geom thread that calls
	 * g_sched_init() might actually run after g_gsched_modevent(),
	 * so make sure that the module is properly initialized.
	 */