mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-13 03:07:36 +08:00
px4_work_queue: directly support SITL lockstep
- the purpose is to ensure that every WorkItem (and WorkItems scheduled by WorkItems) is allowed to run to completion every step - per workqueue register a lockstep component whenever a work item is added (if not already registered) - once the work queue is empty unregister component
This commit is contained in:
committed by
Lorenz Meier
parent
8c71ecd97e
commit
98cff94702
@@ -106,6 +106,15 @@ void WorkQueue::Detach(WorkItem *item)
|
||||
void WorkQueue::Add(WorkItem *item)
|
||||
{
|
||||
work_lock();
|
||||
|
||||
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
|
||||
if (_lockstep_component == -1) {
|
||||
_lockstep_component = px4_lockstep_register_component();
|
||||
}
|
||||
|
||||
#endif // ENABLE_LOCKSTEP_SCHEDULER
|
||||
|
||||
_q.push(item);
|
||||
work_unlock();
|
||||
|
||||
@@ -158,6 +167,15 @@ void WorkQueue::Run()
|
||||
work_lock(); // re-lock
|
||||
}
|
||||
|
||||
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
|
||||
if (_q.empty()) {
|
||||
px4_lockstep_unregister_component(_lockstep_component);
|
||||
_lockstep_component = -1;
|
||||
}
|
||||
|
||||
#endif // ENABLE_LOCKSTEP_SCHEDULER
|
||||
|
||||
work_unlock();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user