From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 13 06:45:14 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 5693E16A41F for ; Fri, 13 Jan 2006 06:45:14 +0000 (GMT) (envelope-from kamal_ckk@yahoo.com) Received: from web30006.mail.mud.yahoo.com (web30006.mail.mud.yahoo.com [68.142.200.69]) by mx1.FreeBSD.org (Postfix) with SMTP id E37F243D46 for ; Fri, 13 Jan 2006 06:45:13 +0000 (GMT) (envelope-from kamal_ckk@yahoo.com) Received: (qmail 73472 invoked by uid 60001); 13 Jan 2006 06:45:13 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=0imxCIktBBe5+a0SDaOv3Y284ZoIIVk+oUH7japitsXm6kTD51PqoH7UtslL91UCUnvI7mvNNczggnMoux/jwGBCZoYXqW0w6oXOLZEHBId7LfKNHiT9lCvsXmgKtLihCodbb4qk7mssj8dh0L9WoCUdET6W0+95C2HQEtMtN44= ; Message-ID: <20060113064513.73470.qmail@web30006.mail.mud.yahoo.com> Received: from [202.161.131.69] by web30006.mail.mud.yahoo.com via HTTP; Thu, 12 Jan 2006 22:45:13 PST Date: Thu, 12 Jan 2006 22:45:13 -0800 (PST) From: kamal kc To: freebsd In-Reply-To: <200601121410.53884.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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: Fri, 13 Jan 2006 06:45:14 -0000 --- John Baldwin wrote: > 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 .... the problem is solved i guess. now i used the structure : struct taskqueue_struct { struct task mytask; int a; int b; } everytime i call TASK_INIT() i allocate memory for the taskqueue_struct. and in the handler function deallocate the struct taskqueue_struct. this allowed me to do memory safe operation i guess !! > > 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. yes , i will do these things. now i will try to make a separate taskqueue thread for the job like you said before. i am looking at the kthread and other stuffs. i am more optimistic now than ever.. i am enjoying these stuffs .. thanks, kamal __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com