From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 12 11:17:45 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 359091065674 for ; Mon, 12 Sep 2011 11:17:45 +0000 (UTC) (envelope-from loerner@gmx.de) Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mx1.freebsd.org (Postfix) with SMTP id 9DC378FC17 for ; Mon, 12 Sep 2011 11:17:44 +0000 (UTC) Received: (qmail 22319 invoked by uid 0); 12 Sep 2011 11:17:43 -0000 Received: from 212.185.199.2 by www062.gmx.net with HTTP; Mon, 12 Sep 2011 13:17:41 +0200 (CEST) Content-Type: text/plain; charset="utf-8" Date: Mon, 12 Sep 2011 13:17:41 +0200 From: =?iso-8859-1?Q?=22Marc_L=F6rner=22?= In-Reply-To: <9B13644B-F61E-4761-8C4F-E9E33F6E82B8@gmail.com> Message-ID: <20110912111741.298340@gmx.net> MIME-Version: 1.0 References: <20110912094842.251380@gmx.net> <9B13644B-F61E-4761-8C4F-E9E33F6E82B8@gmail.com> To: Filippo Sironi X-Authenticated: #60932973 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX19SygZP+EFSvmTMxromH/v+b5U/JwQGSYmCtSh5Rl mdYdA6wnxi6V1oxqeLNSzJ+OIrYb2Zz3ub0w== Content-Transfer-Encoding: 8bit X-GMX-UID: bdhUe7E5eWUoTQWi0nZz9B0xU3U4N8/a X-Mailman-Approved-At: Mon, 12 Sep 2011 11:42:47 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel timers infrastructure X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2011 11:17:45 -0000 Hello again, it seems that uprintf needs a tty to put output to. I tried your code with printf instead of uprintf and got output to root-console ttyu0 every second. HTH, Marc -------- Original-Nachricht -------- > Datum: Mon, 12 Sep 2011 11:58:37 +0200 > Von: Filippo Sironi > An: "Marc Lörner" > CC: freebsd-hackers@freebsd.org > Betreff: Re: Kernel timers infrastructure > This is how I modified the module: > -------------------------------------------------------------------------------- > #include > #include > #include > #include > > static struct callout timer_callout; > > static void > timer_function(void *arg) > { > uprintf("timer_function() begin\n"); > if (callout_reset(&timer_callout, hz, timer_function, NULL)) > uprintf("callout_reset() != 0\n"); > uprintf("Hello, World!\n"); > uprintf("timer_function() end\n"); > } > > static int > timer_event_handler(struct module *mod, int cmd, void *arg) > { > uprintf("timer_event_handler() begin\n"); > switch (cmd) { > case MOD_LOAD: > uprintf("MOD_LOAD\n"); > callout_init(&timer_callout, CALLOUT_MPSAFE); > if (callout_reset(&timer_callout, hz, timer_function, NULL)) > uprintf("callout_reset() != 0\n"); > break; > case MOD_UNLOAD: > uprintf("MOD_UNLOAD\n"); > callout_drain(&timer_callout); > break; > case MOD_SHUTDOWN: > uprintf("MOD_SHUTDOWN\n"); > break; > default: > return EOPNOTSUPP; > } > uprintf("timer_event_handler() end\n"); > return 0; > } > > static struct moduledata timer_moduledata = { > "timer", > timer_event_handler, > NULL > }; > > DECLARE_MODULE(timer, timer_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); > -------------------------------------------------------------------------------- > and this is the output of load and unload operations: > freebsd# kldload ./timer.ko > timer_event_handler() begin > MOD_LOAD > timer_event_handler() end > freebsd# kldunload timer.ko > timer_event_handler() begin > timer_event_handler() begin > MOD_UNLOAD > timer_event_handler() end > > I don't know why "timer_event_handler() begin" is printed twice on unload > but the timer doesn't start... and of course it is set on 1 second but I > left the module load for 1 minute or so just to be sure. ;) > > Thanks again for your help, > Filippo > > On 12/set/2011, at 11:48, Marc Lörner wrote: > > > Hello, > > what about changing order of callout_reset and uprintf? > > And your timeout isn't 1minute, it's one second! > > > > Regards, > > Marc > > -- > > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de > -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de