From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 12 19:26:20 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5E1F216A41F for ; Thu, 12 Jan 2006 19:26:20 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACC1543D49 for ; Thu, 12 Jan 2006 19:26:18 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 5911740 for multiple; Thu, 12 Jan 2006 14:24:44 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k0CJQF2G085257; Thu, 12 Jan 2006 14:26:15 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 12 Jan 2006 14:10:51 -0500 User-Agent: KMail/1.8.2 References: <20060112111905.85809.qmail@web30006.mail.mud.yahoo.com> In-Reply-To: <20060112111905.85809.qmail@web30006.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601121410.53884.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1239/Thu Jan 12 06:36:22 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: kamal kc Subject: Re: rescheduling tasks using swi_add() 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: Thu, 12 Jan 2006 19:26:20 -0000 On Thursday 12 January 2006 06:19 am, kamal kc wrote: > --- kamal kc wrote: > > > Queue a task to a taskqueue. Behind the scenes > > > > that > > > > > will invoke a swi_add if > > > you use the taskqueue_swi queue. However, given > > > that you want to do some > > > rather complicated work, you'd be better off > > > creating a dedicated taskqueue > > > thread and queueing tasks off to it I think. > > > > thanks for the suggestion on the taskqueue. i tried > > it > > > > on my dummy kernel module and got some output but i > > am not sure if i followed the correct steps to > > use the taskqueue. the only thing i found > > was the man pages and the taskqueue.h. > > > > here is the code: > > ----------------------- > > > > struct taskqueue_arguments > > { int a; > > int b; > > }; > > > > void taskqueue_function(void *,int); > > typedef void taskqueue_function_t(void *,int); > > > > /* taskqueue function */ > > void taskqueue_function(void *arguments,int int_arg) > > { > > struct taskqueue_arguments *arg; > > arg=(struct taskqueue_arguments *)arguments; > > printf("\ntakqueue_function was called the args > > are %d %d",arg->a,arg->b); > > return; > > } > > > > /* function implementing the syscall */ > > static int > > hello(struct thread *td, void *arg) > > { ......... > > struct task mytask; > > taskqueue_function_t *taskqueue_function_ptr; > > taskqueue_function_ptr=taskqueue_function; > > > > struct taskqueue_arguments arg_var; > > arg_var.a=10; > > arg_var.b=20; > > TASK_INIT(&mytask,50,taskqueue_function_ptr,&arg_var); > > > taskqueue_enqueue(taskqueue_swi, &mytask); You can just use the name of the function w/o having to have an explicit function pointer var: TASK_INIT(&mytask, 50, taskqueue_functino, &arg_var); > > > > ........... > > } > > dear all , > > i run the above code and the kernel > would crash whenever i would do the syscall for few > number of times. the crashing process is > (swi6: task queue). the kernel crashes very soon > when i make the system call in a loop. > > i guess i didn't follow all the steps to use > the taskqueue .... > > i think some of you can help what did i > miss .... Are you calling TASK_INIT() while your task is still pending? Just init the task the first time, then call enqueue() to queue it up. You might want to call TASK_INIT() during the MOD_LOAD() event in your module handler for example. Be sure to call taskqueue_drain() during MOD_UNLOAD() to make sure your task has finished all the pending executes before your module is unloaded as well. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org