From 9b6e270b978d3f32a017faeb23c144c39102cf94 Mon Sep 17 00:00:00 2001
From: Andrew Johnson
Date: Thu, 24 Jul 2014 16:33:35 -0500
Subject: [PATCH] Final spinlock tidying-up
* Abort epicsSpinTest() if epicsSpinCreate() returns NULL
* Adjust RELEASE_NOTES that describe the implementations.
---
documentation/RELEASE_NOTES.html | 13 +++++++------
src/libCom/test/epicsSpinTest.c | 6 +++++-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html
index d20d9bc65..f2f137e16 100644
--- a/documentation/RELEASE_NOTES.html
+++ b/documentation/RELEASE_NOTES.html
@@ -117,12 +117,13 @@ The basic rules which device support must follow are:
The new header file epicsSpin.h adds a portable spin-locks API which is
intended for locking very short sections of code (typically one or two lines of
C or C++) to provide a critical section that protects against race conditions.
-On Posix platforms this uses the pthread_spinlock_t type if it's available but
-falls back to a pthread_mutex_t if not; on the UP VxWorks and RTEMS platforms
-the implementations lock out the CPU interrupts; the default implementation
-(used where no better implementation is available for the platform) uses an
-epicsMutex. Spin-locks may not be taken recursively, and the code inside the
-critical section should always be short and deterministic.
+On Posix platforms this uses the pthread_spinlock_t type if it's available and
+the build is not configured to use Posix thread priorities, but otherwise it
+falls back to a pthread_mutex_t. On the UP VxWorks and RTEMS platforms the
+implementations lock out CPU interrupts and disable task preemption while a
+spin-lock is held. The default implementation (used when no other implementation
+is provided) uses an epicsMutex. Spin-locks may not be taken recursively, and
+the code inside the critical section should be short and deterministic.
Improvements to aToIPAddr()
diff --git a/src/libCom/test/epicsSpinTest.c b/src/libCom/test/epicsSpinTest.c
index 707345b89..ff2a89c85 100644
--- a/src/libCom/test/epicsSpinTest.c
+++ b/src/libCom/test/epicsSpinTest.c
@@ -94,6 +94,8 @@ void epicsSpinPerformance ()
/* Initialize spinlock */
spin = epicsSpinCreate();
+ if (!spin)
+ testAbort("epicsSpinCreate() returned NULL");
/* test a single lock pair */
epicsTimeGetCurrent(&begin);
@@ -126,7 +128,7 @@ static void verifyTryLock()
{
struct verifyTryLock verify;
- verify.spin = epicsSpinCreate();
+ verify.spin = epicsSpinMustCreate();
verify.done = epicsEventMustCreate(epicsEventEmpty);
testOk1(epicsSpinTryLock(verify.spin) == 0);
@@ -159,6 +161,8 @@ MAIN(epicsSpinTest)
verifyTryLock();
spin = epicsSpinCreate();
+ if (!spin)
+ testAbort("epicsSpinCreate() returned NULL");
id = (epicsThreadId *) calloc(nthreads, sizeof(epicsThreadId));
name = (char **) calloc(nthreads, sizeof(char *));