ftrias / TeensyThreads

MIT License
178 stars 26 forks source link

Question on use of thread_count #38

Open Defragster opened 1 year ago

Defragster commented 1 year ago

Looking at output from char *Threads::threadsInfo(void) { static char _buffer[Threads::UTIL_TRHEADS_BUFFER_LENGTH]; uint _buffer_cursor = 0; _buffer_cursor = sprintf(_buffer, "_____\n"); for (int each_thread = 0; each_thread <= thread_count; each_thread++) That starts on [0] to [3] with 4 added threads without the added "<=" then it runs and shows the 5 actual threads.

thread_count seems to start at 0 even though there is always 1 main thread? It is only incremented with add_thread.

Wondering about other references to thread_count in TeensyThreads.cpp that start at 0 like this: //get lowest sleep interval from sleeping tasks into task_id_ends for (i = 0; i < thread_count; i++) {

Also - maybe threadsinfo() was meant to SKIP [0] - the stack info printed is showing bad numbers - at least on a T_3.5: 0:Stack size:10240|Used:537067512|Remains:-537057272|State:RUNNING|