Date: Mon, 25 Jul 2011 16:26:51 +0100 (BST) From: Robert Watson <rwatson@FreeBSD.org> To: Filippo Sironi <filippo.sironi@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel timers infrastructure Message-ID: <alpine.BSF.2.00.1107251621310.50442@fledge.watson.org> In-Reply-To: <3AD5705F-0C4E-43CB-8A9C-3416171AEA30@gmail.com> References: <3AD5705F-0C4E-43CB-8A9C-3416171AEA30@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 25 Jul 2011, Filippo Sironi wrote: > I'm working on a university project that's based on FreeBSD and I'm > currently hacking the kernel... but I'm a complete newbie. My question is: > what if I have to call a certain function 10 times per second? I've seen a > bit of code regarding callout_* functions but I can't get through them. Is > there anyone who can help me? Hi Filippo: I'm not sure if you've found the callout(9) man page yet, but it talks about the KPI in some detail. The basic idea, though, is that you describe a regular "callout" using a function pointer, an opaque data pointer, and how long until it should be invoked. In its more complex incantations, you can also specify locks for it to acquire, etc. The key aspect of the API that some people find confusing is that the time interval is described in ticks of length 1/hz seconds. Unless software really wants one invocation per tick (generally unlikely), you will want to pass in some constant times/divided by hz so that it's appropriately scaled. You can find two fairly straight-forward examples in kern/uipc_domain.c, which are respectively the "fast" and "slow" timers Robert
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1107251621310.50442>