From owner-freebsd-arch@FreeBSD.ORG Sat Dec 17 11:31:57 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 55A59106566B for ; Sat, 17 Dec 2011 11:31:57 +0000 (UTC) (envelope-from gljennjohn@googlemail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id DF77C8FC13 for ; Sat, 17 Dec 2011 11:31:56 +0000 (UTC) Received: by eaaf13 with SMTP id f13so5047918eaa.13 for ; Sat, 17 Dec 2011 03:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; bh=CQFfUT/ksOd9Mr3SzmnCRDWtLSfGG+odMnAeDPxD5mM=; b=FliIjB5Z2dfLNPK/bgCTuAyjtMKBQIdeyQdqubtysL1xgKys7FWZZwOohJJO3lqJRd ujD0MhIAgk20ZseLTy6G8mmjY696VtxjBJzpzKEAszn4sT0qRqn6fKRKWn1Ioi9V6cmx tMC+kMyVCviD98ZEb6jtdEGOM2rOIQhGZ4YsY= Received: by 10.213.21.147 with SMTP id j19mr1100978ebb.149.1324120102875; Sat, 17 Dec 2011 03:08:22 -0800 (PST) Received: from ernst.jennejohn.org (p578E2767.dip.t-dialin.net. [87.142.39.103]) by mx.google.com with ESMTPS id z54sm12741322eeh.5.2011.12.17.03.08.21 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 17 Dec 2011 03:08:22 -0800 (PST) Date: Sat, 17 Dec 2011 12:08:20 +0100 From: Gary Jennejohn To: freebsd-arch@freebsd.org Message-ID: <20111217120820.5c2d0ee4@ernst.jennejohn.org> In-Reply-To: <201112161559.36428.jhb@freebsd.org> References: <201112161559.36428.jhb@freebsd.org> X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.6; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: TASK_INITIALIZER() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gljennjohn@googlemail.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2011 11:31:57 -0000 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? -- Gary Jennejohn