epicsSpin: try lock return non-blocking
Avoid cantProceed() in try lock, even for undefined behavior.
This commit is contained in:
1 parent
5824f98972
commit
8fec9d6e00
2 files changed
+22
-3
No files matched your search
@@ -59,7 +59,6 @@ void epicsSpinLock(epicsSpinId spin) {
|
||||
rtems_interrupt_level level;
|
||||
rtems_interrupt_disable (level);
|
||||
_Thread_Disable_dispatch();
|
||||
spin->level = level;
|
||||
if(spin->locked) {
|
||||
rtems_interrupt_enable (level);
|
||||
_Thread_Enable_dispatch();
|
||||
@@ -71,11 +70,21 @@ void epicsSpinLock(epicsSpinId spin) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
spin->level = level;
|
||||
spin->locked = 1;
|
||||
}
|
||||
|
||||
int epicsSpinTryLock(epicsSpinId spin) {
|
||||
epicsSpinLock(spin);
|
||||
rtems_interrupt_level level;
|
||||
rtems_interrupt_disable (level);
|
||||
_Thread_Disable_dispatch();
|
||||
if(spin->locked) {
|
||||
rtems_interrupt_enable (level);
|
||||
_Thread_Enable_dispatch();
|
||||
return 1;
|
||||
}
|
||||
spin->level = level;
|
||||
spin->locked = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,17 @@ void epicsSpinLock(epicsSpinId spin) {
|
||||
}
|
||||
|
||||
int epicsSpinTryLock(epicsSpinId spin) {
|
||||
epicsSpinLock(spin);
|
||||
int key = intLock();
|
||||
if(!intContext())
|
||||
taskLock();
|
||||
if(spin->locked) {
|
||||
intUnlock(key);
|
||||
if(!intContext())
|
||||
taskUnlock();
|
||||
return 1;
|
||||
}
|
||||
spin->key = key;
|
||||
spin->locked = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user