Sleeping in the work_queue

This is my first time posting here, I am working on my first driver for PX4.

The developer guide states: “A task is scheduled by specifying a fixed time in the future. The advantage is that it uses less RAM, but the task is not allowed to sleep or poll on a message.”

I wanted to ask what the consequences of sleeping in the work_queue are? Is this a single threaded work queue and thus a sleep blocks and prevents other scheduled tasks from executing?

The reason I ask is I am interfacing with an ultrasonic driver over UART and there are many places where I need to wait until the device completes a task before moving on. (ie: take a measurement, write to eeprom, poll on a register write/read response)


I should also mention – many of the drivers I’ve referenced that use the work_queue use sleeps.

MPU9250 – reset

hmc5883 – conversion interval

bmp280 – set_register, collect, measure

I would think that if this was an issue (sleeps = blocking) then there would be problems running all these drivers on the work_queue (throttled execution)

I have done some investigation and can confirm my assumption was correct, if I sleep in the work_queue I throttle the crap out of my other work_queue tasks (via uorb top – publish rates drop substantially depending on sleep duration)


Yes that is correct, and the reason for avoiding it. A UART driver generally better runs in its own task.