-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PX4 general work queue #8814
Comments
Nice! I should be ready for this mid week. |
I'm thinking about a concept of an event queue as a more generalized version of a work queue. The events get processed by an event processor, which executes the work in a callback. Until here, the result is similar to the work queue. However, an event queue can also take uORB events. The event processor can invoke a call to the right module. This way we can pull multiple modules (that are now running at same priority level anyway) into a single thread. An event queue can also accept timing events, which can be published from hrt timer interrupts on intervals configured by hrt_call_every() for example. It is also possible to have several event queues with different priorities in parallel, although it will not preempt a lower priority event processing function when a high priority event arrives. If that is required, another event queue + processor can be added in another thread with higher priority. |
Sounds good to me. The other piece of this I didn't mention above (perhaps the killer feature) was an orb mechanism for queuing work items on publish. |
Minor update, but I believe we straightened out many of the priorities (https://github.com/PX4/Firmware/blob/master/src/platforms/px4_tasks.h) after following up with that AeroVinci PX4 blog post (http://px4.io/aerovinci-scalable-flexible-dronedock-system/). |
So what I really ment to say was: This way we can pull multiple modules (whose code is now executed sequentially anyway) into a single thread |
Absolutely! |
I'm working on something that's going to look a bit like this. It is a work queue which can be linked to uORB topics. First of all, uORB is extended to support callbacks on publications: But actually this is going to be encapsulated by the work queue client, which will behave something like this:
In the background, there is a Still very conceptual and WIP. |
In which context is this going to be called? On the publishing task? If so, you defeat the purpose of uORB - passing messages to different tasks. If on the calling task you're going to need an event loop (which is what we do with poll()). Otherwise I like the concept of a general work queue if we can get an efficient implementation. |
It will be called on |
I'm not sure if you want to build that into uorb then or just add that into the work queue (since it's a specific use-case). But let's see. |
The idea is that you want to register something such that every orb publish results in a work item being added to the queue. We can register it once (module "start") and skip every cycle doing the poll setup, poll teardown, locking, etc. The goal is to be able to use it for inherently serialized processes with minimal latency. For example the rate controller and output module (mixing + pwm) could share a thread in this new work queue. The rate controller's actuator_control orb publication results in a px4fmu work item inserted to run immediately. In this case they'd run back to back without a context switch and without the need for a task each. |
Ok sounds interesting. On the critical path we have 2 task switches that minimally take 31us each. The control latency is 215us on the bench, so we could save a bit there, assuming the work-queue implementation is efficient. |
The text was updated successfully, but these errors were encountered: