epicsSpin: try lock return non-blocking
Avoid cantProceed() in try lock, even for undefined behavior.
This commit is contained in:
@@ -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