Hi!
I've wrapped up an outline patch for what needs to be done to integrate the
USB process framework into the kernel taskqueue system in a more direct way
that to wrap it.
The limitation of the existing taskqueue system is that it only guarantees
execution at a given priority level. USB requires more. USB also requires a
guarantee that the last task queued task also gets executed last. This is for
example so that a deferred USB detach event does not happen before any pending
deferred I/O for example in case of multiple occurring events.
Mostly this new feature is targeted for GPIO-alike system using slow busses
like the USB. Typical use case:
2 tasks to program GPIO on.
2 tasks to program GPIO off.
Example:
a) taskqueue_enqueue_odd(&sc->sc_taskqueue, &sc->sc_task_on[0], &sc-
b) taskqueue_enqueue_odd(&sc->sc_taskqueue, &sc->sc_task_off[0], &sc-
No matter how the call ordering of code-line a) and b), we are always
guaranteed that the last queued state "on" or "off" is reached before the head
of the taskqueue empties.
In lack of a better name, the new function was called taskqueue_enqueue_odd
[some people obviously think that USB processes are odd, but not taskqueues
:-)]
Manpage:
.Ft int
.Fn taskqueue_enqueue_odd "struct taskqueue *queue" "struct task *t0" "struct
task *t1"
..
The function
.Fn taskqueue_enqueue_odd
should be used if it is important that the last queued task is also
executed last in the task queue at the given priority level. This
function requires two valid task pointers. Depending on which of the
tasks passed are queued at the calling moment, the last queued task of
the two will get dequeued and put last in the task queue, while not
touching the first queued task. If no tasks are queued at the calling
moment, this function behaves like
.Fn taskqueue_enqueue .
This function returns zero if the first task was queued last, one if
the second task was queued last.
Preliminary patch - see e-mail attachment.
Comments are welcome!
--HPS
More docs: Also see talk about the new USB stack in FreeBSD on Youtube.