From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 12 09:58:41 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 8E1861065675 for ; Mon, 12 Sep 2011 09:58:41 +0000 (UTC) (envelope-from filippo.sironi@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 4D3508FC08 for ; Mon, 12 Sep 2011 09:58:40 +0000 (UTC) Received: by qyk10 with SMTP id 10so1444074qyk.13 for ; Mon, 12 Sep 2011 02:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:x-priority:in-reply-to:date :cc:content-transfer-encoding:message-id:references:to:x-mailer; bh=UFV+bV97mfXesT7ygoc89zcHWijcIgHFniSsDg4cXKA=; b=MH9WgDlza13OjbAEZH2sJrwujE+Vly4Fahy1fOpjGdfvgyFYdxdMkeEPhGnySLu67u gkQvENpWaoD1GM3uNaYzqpNJG4gzrlLPj+F5/pxX9uL/phKGe/vsEKQNZfFMVZblmsBX z85uzG8JZTSnFya6IWmtjDPLUQ3kyurquIe80= Received: by 10.224.9.14 with SMTP id j14mr1129200qaj.376.1315821520559; Mon, 12 Sep 2011 02:58:40 -0700 (PDT) Received: from filippo.sironi.dynamic.micro.elet.polimi.it (micro.elet.polimi.it. [131.175.127.118]) by mx.google.com with ESMTPS id el2sm12177250qab.2.2011.09.12.02.58.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Sep 2011 02:58:39 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: text/plain; charset=iso-8859-1 From: Filippo Sironi X-Priority: 3 In-Reply-To: <20110912094842.251380@gmx.net> Date: Mon, 12 Sep 2011 11:58:37 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9B13644B-F61E-4761-8C4F-E9E33F6E82B8@gmail.com> References: <20110912094842.251380@gmx.net> To: =?iso-8859-1?Q?=22Marc_L=F6rner=22?= X-Mailer: Apple Mail (2.1244.3) 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 09:58:41 -0000 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() !=3D 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() !=3D 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 =3D { "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=F6rner wrote: > Hello, > what about changing order of callout_reset and uprintf? > And your timeout isn't 1minute, it's one second! >=20 > Regards, > Marc > --=20 > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de