Kernel timers infrastructure

Filippo Sironi filippo.sironi at gmail.com
Mon Sep 12 09:11:58 UTC 2011


This is what I wrote for FreeBSD 7.2 and it does not work:
--------------------------------------------------------------------------------
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>

static struct callout timer_callout;

static void
timer_function(void *arg)
{
	if (callout_reset(&timer_callout, hz, timer_function, NULL))
		uprintf("callout_reset() != 0\n");
	uprintf("Hello, World!\n");
}

static int
timer_event_handler(struct module *mod, int cmd, void *arg)
{
	switch (cmd) {
	case MOD_LOAD:
		callout_init(&timer_callout, CALLOUT_MPSAFE);
		if (callout_reset(&timer_callout, hz, timer_function, NULL))
			uprintf("callout_reset() != 0\n");
		break;
	case MOD_UNLOAD:
		callout_drain(&timer_callout);
		break;
	case MOD_SHUTDOWN:
		break;
	default:
		return EOPNOTSUPP;
	}
	return 0;
}

static struct moduledata timer_moduledata = {
	"timer",
	timer_event_handler,
	NULL
};

DECLARE_MODULE(timer, timer_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
--------------------------------------------------------------------------------
but I do not know why...
I basically run through many different examples I found within the kernel and they are not different from this module.

Does anyone see any clear issue?

Filippo

On 10/set/2011, at 19:39, Riccardo Cattaneo wrote:

> Hi all,
> Me in the same situation: university project, freebsd os, required to call a certain function X times/second (say, uprintf).
> Got no luck till now :(
> Thanks
> Riccardo_______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"



More information about the freebsd-hackers mailing list