@@ -114,7 +114,7 @@ extern "C" {
114114#endif // ESP32_FREERTOS
115115}
116116
117- std::array< std::atomic<CoopTaskBase* >, CoopTaskBase::MAXNUMBERCOOPTASKS> CoopTaskBase::runnableTasks{};
117+ std::array< std::atomic<CoopTaskBase* >, CoopTaskBase::MAXNUMBERCOOPTASKS + 1 > CoopTaskBase::runnableTasks {};
118118std::atomic<size_t > CoopTaskBase::runnableTasksCount (0 );
119119
120120CoopTaskBase* CoopTaskBase::current = nullptr ;
@@ -174,11 +174,11 @@ bool CoopTaskBase::rescheduleTask(uint32_t repeat_us)
174174}
175175#endif
176176
177- bool CoopTaskBase::enrollRunnable ()
177+ bool IRAM_ATTR CoopTaskBase::enrollRunnable ()
178178{
179179 bool enrolled = false ;
180180 bool inserted = false ;
181- for (size_t i = 0 ; i < CoopTaskBase::MAXNUMBERCOOPTASKS ; ++i)
181+ for (size_t i = 0 ; i < runnableTasks. size () ; ++i)
182182 {
183183#if !defined(ESP32) && defined(ARDUINO)
184184 InterruptLock lock;
@@ -235,7 +235,7 @@ void CoopTaskBase::delistRunnable()
235235{
236236#if !defined(ESP32) && defined(ARDUINO)
237237 InterruptLock lock;
238- for (size_t i = 0 ; i < CoopTaskBase::MAXNUMBERCOOPTASKS ; ++i)
238+ for (size_t i = 0 ; i < runnableTasks. size () ; ++i)
239239 {
240240 if (runnableTasks[i].load () == this )
241241 {
@@ -245,7 +245,7 @@ void CoopTaskBase::delistRunnable()
245245 }
246246 }
247247#else
248- for (size_t i = 0 ; i < CoopTaskBase::MAXNUMBERCOOPTASKS ; ++i)
248+ for (size_t i = 0 ; i < runnableTasks. size () ; ++i)
249249 {
250250 CoopTaskBase* self = this ;
251251 if (runnableTasks[i].compare_exchange_strong (self, nullptr ))
@@ -646,7 +646,7 @@ CoopTaskBase* CoopTaskBase::self() noexcept
646646 const auto currentTaskHandle = xTaskGetCurrentTaskHandle ();
647647 auto cur = current;
648648 if (cur && currentTaskHandle == cur->taskHandle ) return cur;
649- for (size_t i = 0 ; i < CoopTaskBase::MAXNUMBERCOOPTASKS ; ++i)
649+ for (size_t i = 0 ; i < runnableTasks. size () ; ++i)
650650 {
651651 cur = runnableTasks[i].load ();
652652 if (cur && currentTaskHandle == cur->taskHandle ) return cur;
@@ -804,11 +804,11 @@ void CoopTaskBase::dumpStack() const
804804#endif
805805 while (pos < (taskStackSize + (FULLFEATURES ? sizeof (STACKCOOKIE) : 0 )) / sizeof (STACKCOOKIE))
806806 {
807+ #ifndef ARDUINO_attiny
807808 auto * sp = &reinterpret_cast <unsigned *>(taskStackTop)[pos];
808809
809810 // rough indicator: stack frames usually have SP saved as the second word
810811 bool looksLikeStackFrame = (sp[2 ] == reinterpret_cast <size_t >(&sp[4 ]));
811- #ifndef ARDUINO_attiny
812812 ::printf (PSTR(" %08x: %08x %08x %08x %08x %c\n " ),
813813 reinterpret_cast<size_t>(sp), sp[0], sp[1], sp[2], sp[3], looksLikeStackFrame ? '<' : ' ');
814814#endif
0 commit comments