defragster
Senior Member+
@ftrias - not done anything beyond initial test yet that worked as noted. Added yield() to threads for them to exit after being done some simple task - in minor change to the example\print.ino.
I noticed I skewed the run/exec time of the threads shared with loop() - and it took some added code to discover how/why as it was odd behavior of the non-linear switching operation.
>> Wondering if there would be an easy way to add '#ifdef DEBUG' instrumentation that could give thread operation feedback?
like :
When a thread is started: thread_X.cyclesStart = ARM_DWT_CYCCNT
When a thread is swapped for time or yield: thread_X.cyclesAccum += ARM_DWT_CYCCNT - thread_X.cyclesStart
Then once per second or so a print of cycles/time spent per thread would show inactive or long running threads by getting and zeroing the cyclesAccum per thread? Along the lines of what the Audio Library shows with CPU_USE.
>> Not followed the code develop or seen how time is allowed for loop() to run?
>> There is 'thread 0, which is always running' - is that just the default task switch thread?
>> Would be interesting to know how much time is spent in in loop() from the above - as it was only counting loop()/sec that told of the off thread behavior I created.
Perhaps there are better or additional ways to get feedback that might give a feel for where the time goes when something isn't clicking right? The read of the ARM_DWT_CYCCNT is a fast 'memory' read so would add minimal over head '#ifdef DEBUG'.
I noticed I skewed the run/exec time of the threads shared with loop() - and it took some added code to discover how/why as it was odd behavior of the non-linear switching operation.
>> Wondering if there would be an easy way to add '#ifdef DEBUG' instrumentation that could give thread operation feedback?
like :
Code:
class ThreadInfo {
public:
uint32_t cyclesStart=0; // On T_4 the CycCnt is always active - on T_3.x it currently is not - unless Audio starts it AFAIK
uint32_t cyclesAccum=0;
When a thread is started: thread_X.cyclesStart = ARM_DWT_CYCCNT
When a thread is swapped for time or yield: thread_X.cyclesAccum += ARM_DWT_CYCCNT - thread_X.cyclesStart
Then once per second or so a print of cycles/time spent per thread would show inactive or long running threads by getting and zeroing the cyclesAccum per thread? Along the lines of what the Audio Library shows with CPU_USE.
>> Not followed the code develop or seen how time is allowed for loop() to run?
>> There is 'thread 0, which is always running' - is that just the default task switch thread?
>> Would be interesting to know how much time is spent in in loop() from the above - as it was only counting loop()/sec that told of the off thread behavior I created.
Perhaps there are better or additional ways to get feedback that might give a feel for where the time goes when something isn't clicking right? The read of the ARM_DWT_CYCCNT is a fast 'memory' read so would add minimal over head '#ifdef DEBUG'.