Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Dec 2011 12:09:21 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        gljennjohn@googlemail.com
Cc:        freebsd-arch@freebsd.org
Subject:   Re: TASK_INITIALIZER()
Message-ID:  <4EEF6FC1.8020306@FreeBSD.org>
In-Reply-To: <20111217120820.5c2d0ee4@ernst.jennejohn.org>
References:  <201112161559.36428.jhb@freebsd.org> <20111217120820.5c2d0ee4@ernst.jennejohn.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/17/11 6:08 AM, Gary Jennejohn wrote:
> On Fri, 16 Dec 2011 15:59:36 -0500
> John Baldwin<jhb@freebsd.org>  wrote:
>
>> Any objection to adding a macro to make it easy to statically initialize task
>> structures (similar to the initializer macros in<sys/queue.h>)?  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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EEF6FC1.8020306>