Skip to content

Commit 4f09a64

Browse files
committed
protect critical sections
1 parent 1674c72 commit 4f09a64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cores/esp8266/Schedule.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ bool schedule_function_us(mFuncT fn, uint32_t repeat_us)
4646
return false;
4747
}
4848
item->mFunc = fn;
49+
50+
noInterrupts();
4951
item->mNext = sFirst;
5052
sFirst = item;
53+
interrupts();
54+
5155
if (repeat_us)
5256
item->callNow.reset(repeat_us);
5357
return true;
@@ -64,9 +68,13 @@ void run_scheduled_functions()
6468
while (toCall) {
6569
scheduled_fn_t* item = toCall;
6670
toCall = item->mNext;
67-
if (item->callNow && !item->mFunc()) {
71+
if (item->callNow && !item->mFunc())
72+
{
73+
noInterrupts();
6874
if (sFirst == item)
6975
sFirst = item->mNext;
76+
interrupts();
77+
7078
item->mFunc = mFuncT();
7179
recycle_fn(item);
7280
}

0 commit comments

Comments
 (0)