General Question on software timers

Hi experts,

I have a general question on how software timers are working.
As I understood the timers are executed in a separate thread. So they are running in parallel with the loop()?
Will the loop code be halted when a timer is triggered, or will it run in “parallel”?
Or is the timer always be executed at the beginning or the end of a loop()?

Can I use SINGLE_THREADED_BLOCK() to control when in the loop a timer can be executed and not?

First I have used a simple if statement in my code to do something every some seconds if (time_stamp < millis()) and there I had the control over the point in time in my code.
With the software timers it seems like I am loosing this and need to handle this somehow different. Is this correct?

There is no real parallel execution on a single core processor.
The virtual parallelism is achieved via FreeRTOS time slicing the controller. The individual time slices are 1ms and the pending/waiting threads get their time slice in a round-robin manner.

SINGLE_THREADED_BLOCK() ensures that the time slicing does not happen in the middle of the block, but you should not have code in that block that hoggs the controler for too long (max. a few ms).

One of the main advantages of Software Timers is the asynchronous nature of them.


Hi @ScruffR,

thanks for the fast reply.
I think that answers the questions.