What happens when a function lasts longer then defined in AP_Scheduler?

Hello guys,

I’m curious what exactly is the “maximum expected time” parameter used for (set when defining a task for AP_Scheduler). Does the scheduler control function’s timing (and ex. switches to another task at timeout) or is it just an information when to execute it?

I am specifically thinking about the AP_Proximity::update() task scheduled in ArduCopter.cpp which is declared to last for 50us, but takes about 2ms* with RPLidar sensor connected. Does it delay other tasks or is it alright to be like that?

As a side note question, I noticed that printing debug information via UART5 increases the execution time* of the function. Does it mean the data is transmitted directly from where printf(…) was called, i.e. not in a separate task?

(*) I measured the time by setting one of GPIO outputs high/low when entering/leaving the function and scanning it with a logic analyzer. Should be quite accurate, unless the function is interrupted with other tasks in the meantime.

1 Like