FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
05-10-2024 10:31 AM
I'm using the scheduler rt example as a basis for my program and in this moment I have one cycle running with 2ms cycle time in this part of the code:
In addiction to this, I have another cycle (non real time) running in the finalStateMachine. When the state is on SCHED_OPERATING, my cycle runs. So far so good and the code runs well.
My problem is that when I add more code to this part (non real time), some cycles to read info (readsync) and process information, my RealTime cycle is affected and take more time to complete (more than 2ms).
It's supposed the non real time affects the real time process? Or could I be doing something wrong?
Solved! Go to Solution.
05-10-2024 12:49 PM
How do you determine if your code is running in real time or not? It sounds like only have one callable executing both of the code so both also are called every two ms.
05-10-2024 04:02 PM
Yes, it's only one callable. However, in the rt scheduler example, we have this note before the finalStateMachine function:
" //! Implementation of the final state machine, handles none realtime actions (outside the scheduler context)"
So, with this I understand that this function called by a thread is independent of the scheduler. But I can be wrong...
05-14-2024 02:57 PM
Yes you are right. The finalStateMachine() runs in a separate thread and not in the scheduler context. See Callable.cpp line 28-35:
//! Starts the final state machine in a separate thread.
void Callable::finalStateMachineStart()
{
TRACE_INFO("#%d", m_instanceID);
m_finalStateMachineState = FinalStateMachineState::IDLE;
m_thread = std::thread(&Callable::finalStateMachine, this);
}
Thats why we can do a std::this_thread::sleep_for(std::chrono::seconds(1)) in line 196. And the watchdog ist not called.