From owner-freebsd-arch@FreeBSD.ORG Mon Dec 19 17:09:18 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2978106564A for ; Mon, 19 Dec 2011 17:09:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 98A5E8FC17 for ; Mon, 19 Dec 2011 17:09:18 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 49E1F46B09; Mon, 19 Dec 2011 12:09:18 -0500 (EST) Received: from John-Baldwins-MacBook-Air.local (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C7EC2B959; Mon, 19 Dec 2011 12:09:17 -0500 (EST) Message-ID: <4EEF6FC1.8020306@FreeBSD.org> Date: Mon, 19 Dec 2011 12:09:21 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: gljennjohn@googlemail.com References: <201112161559.36428.jhb@freebsd.org> <20111217120820.5c2d0ee4@ernst.jennejohn.org> In-Reply-To: <20111217120820.5c2d0ee4@ernst.jennejohn.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 19 Dec 2011 12:09:17 -0500 (EST) Cc: freebsd-arch@freebsd.org Subject: Re: TASK_INITIALIZER() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2011 17:09:18 -0000 On 12/17/11 6:08 AM, Gary Jennejohn wrote: > On Fri, 16 Dec 2011 15:59:36 -0500 > John Baldwin wrote: > >> Any objection to adding a macro to make it easy to statically initialize task >> structures (similar to the initializer macros in)? This allows >> global tasks to be statically initalized without requiring a dedicated >> SYSINIT() routine. >> >> Index: share/man/man9/Makefile >> =================================================================== >> --- share/man/man9/Makefile (revision 228534) >> +++ share/man/man9/Makefile (working copy) >> @@ -1250,6 +1250,7 @@ >> sysctl_ctx_init.9 sysctl_ctx_free.9 >> MLINKS+=SYSINIT.9 SYSUNINIT.9 >> MLINKS+=taskqueue.9 TASK_INIT.9 \ >> + taskqueue.9 TASK_INITIALIZER.9 \ >> taskqueue.9 taskqueue_cancel.9 \ >> taskqueue.9 taskqueue_create.9 \ >> taskqueue.9 taskqueue_create_fast.9 \ >> Index: share/man/man9/taskqueue.9 >> =================================================================== >> --- share/man/man9/taskqueue.9 (revision 228534) >> +++ share/man/man9/taskqueue.9 (working copy) >> @@ -80,6 +80,7 @@ >> .Ft void >> .Fn taskqueue_run "struct taskqueue *queue" >> .Fn TASK_INIT "struct task *task" "int priority" "task_fn_t func" "void >> *context" >> +.Fn TASK_INITIALIZER "int priority" "task_fn_t func" "void *context" >> .Fn TASKQUEUE_DECLARE "name" >> .Fn TASKQUEUE_DEFINE "name" "taskqueue_enqueue_fn enqueue" "void *context" >> "init" >> .Fn TASKQUEUE_FAST_DEFINE "name" "taskqueue_enqueue_fn enqueue" "void >> *context" "init" >> @@ -243,9 +244,14 @@ >> is provided to initialise a >> .Va task >> structure. >> +The >> +.Fn TASK_INITIALIZER >> +macro generates an initializer for a task structure. >> A macro >> .Fn TIMEOUT_TASK_INIT "queue" "timeout_task" "priority" "func" "context" >> -initializes the timeout_task structure. >> +initializes the >> +.Va timeout_task >> +structure. >> The values of >> .Va priority , >> .Va func , >> Index: sys/sys/taskqueue.h >> =================================================================== >> --- sys/sys/taskqueue.h (revision 228534) >> +++ sys/sys/taskqueue.h (working copy) >> @@ -77,6 +77,12 @@ >> void taskqueue_unblock(struct taskqueue *queue); >> int taskqueue_member(struct taskqueue *queue, struct thread *td); >> >> +#define TASK_INITIALIZER(priority, func, context) \ >> + { .ta_pending = 0, \ >> + .ta_priority = (priority), \ >> + .ta_func = (func), \ >> + .ta_context = (context) } >> + >> /* >> * Functions for dedicated thread taskqueues >> */ >> > > Seems like an excellent idea. Are you also planning to replace the > existing SYSINIT() entries? I had not planned on doing so, no. I can maybe look at that however. -- John Baldwin