Skip to content

Commit a4c1d4e

Browse files
author
dave
committed
#29 do not yield back to task manager in spin lock
1 parent 8f7a7fb commit a4c1d4e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/SimpleSpinLock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool SimpleSpinLock::spinLock(unsigned long iterations) {
3232
return true;
3333
}
3434
else {
35-
taskManager.yieldForMicros(100);
35+
delayMicroseconds(50);
3636
}
3737
--iterations;
3838
}

src/SimpleSpinLock.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
#ifndef TASKMANAGERIO_RENTRANTYIELDINGLOCK_H
77
#define TASKMANAGERIO_RENTRANTYIELDINGLOCK_H
88

9+
#include <IoLogging.h>
910
#include "TaskManagerIO.h"
1011

1112
/**
1213
* A very simple lock that can be used to provide a very simple mutex like behaviour based on task manager
1314
* atomic constructs. It has the ability to try and spin lock, and also to fully lock in conjunction with
14-
* TaskMgrLock class.
15+
* TaskMgrLock class. Use only for activities that do not take very long, it cannot relinquish control to
16+
* task manager, it freezes the bus when locked. You must never call yieldForMicros while locked.
1517
*/
1618
class SimpleSpinLock {
1719
private:

0 commit comments

Comments
 (0)