Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2019 21:30:42 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        "Fedorov, Aleksandr" <aleksandr.fedorov@vstack.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: TASKQUEUE(9) KPI enqueue task only once
Message-ID:  <20190502183042.GH85201@kib.kiev.ua>
In-Reply-To: <05b18f73ee054b9696d055ed40610dea@vstack.com>
References:  <05b18f73ee054b9696d055ed40610dea@vstack.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 ?



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