1
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/mac.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/module.h>
#include <sys/sysctl.h>
 
static MALLOC_DEFINE(M_exam, "exam", "exam");
 
u_long uptime;
 
struct callout_handle mstimer_h;
 
static void 
exam_mstimer(void)
{
	uptime ++;
	mstimer_h = timeout((timeout_t *)&exam_mstimer, NULL, hz / 10);
}
static int
exam_modevent(module_t mod, int type, void *data) 
{
	switch (type) { 
	case MOD_LOAD: 
		mstimer_h = timeout((timeout_t *)&exam_mstimer, NULL, hz / 10);
		break; 
	case MOD_UNLOAD: 
		untimeout((timeout_t *)&exam_mstimer, NULL, mstimer_h);
		mstimer_h.callout = NULL;
		break; 
	default:
		return EOPNOTSUPP;
	} 
	return 0; 
} 
 
 
#ifdef  SYSCTL_OID
SYSCTL_NODE(_net, OID_AUTO, exam, CTLFLAG_RW, 0, "exam");
SYSCTL_UINT(_net_exam, OID_AUTO, count, CTLFLAG_RD, &(uptime), 0, "timer");
 
#endif
 
static moduledata_t exam_mod = { 
	"exam", 
	exam_modevent, 
	0
}; 
 
DECLARE_MODULE(exam, exam_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 
/* end of file *