TASKQUEUE(9) KPI enqueue task only once

Konstantin Belousov kostikbel at gmail.com
Thu May 2 18:30:52 UTC 2019


On Thu, May 02, 2019 at 03:12:30PM +0000, Fedorov, Aleksandr wrote:
> Hi Hackers.
> 
> I need to enqueue task to the taskqueue only if there is no pending tasks.
> 
> I found the taskqueue_poll_is_busy() function, but the comment above indicates that
> it should be used only from single threaded contexts.
> 
> Is there a conventional way to do this?

The reference to the single threaded context above is just a funny way to
say that the function is inherently racy.  It can only work when enqueue
is done from the same thread that executes the task.

Why do you need that ?  Suppose that you have such function, how would
you use it ?  Any check for the running task inside such function cannot
know if the task function is already on the return path and do not
intend to proceed your request that you want to enqueue conditionally.

Or, lets formulate the question differently: what is your problem with
queueing task despite it is already pending or running ?


More information about the freebsd-hackers mailing list