summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-07 12:53:41 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-11 10:58:09 +0100
commit28779c70ffebbb2006eb7df01d64180859bb324e (patch)
tree18a8a77fce926492c090ca2bea21904d743adeb6
parentscore: Add local context to SMP lock API (diff)
downloadrtems-28779c70ffebbb2006eb7df01d64180859bb324e.tar.bz2
score: Add function to destroy SMP locks
-rw-r--r--cpukit/libcsupport/src/termios.c1
-rw-r--r--cpukit/rtems/include/rtems/rtems/intr.h10
-rw-r--r--cpukit/score/include/rtems/score/isrlock.h16
-rw-r--r--cpukit/score/include/rtems/score/smplock.h32
-rw-r--r--testsuites/smptests/smplock01/init.c12
-rw-r--r--testsuites/sptests/sp37/init.c6
-rw-r--r--testsuites/sptests/spcache01/init.c3
-rw-r--r--testsuites/sptests/spnsext01/init.c1
-rw-r--r--testsuites/tmtests/tmcontext01/init.c4
9 files changed, 78 insertions, 7 deletions
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index 6c88de6260..4022e7c516 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -445,6 +445,7 @@ rtems_termios_close (void *arg)
if ((tty->device.pollRead == NULL) ||
(tty->device.outputUsesInterrupts == TERMIOS_TASK_DRIVEN))
rtems_semaphore_delete (tty->rawInBuf.Semaphore);
+ rtems_interrupt_lock_destroy (&tty->interrupt_lock);
free (tty->rawInBuf.theBuf);
free (tty->rawOutBuf.theBuf);
free (tty->cbuf);
diff --git a/cpukit/rtems/include/rtems/rtems/intr.h b/cpukit/rtems/include/rtems/rtems/intr.h
index 62d2dad25a..04bcb72ff4 100644
--- a/cpukit/rtems/include/rtems/rtems/intr.h
+++ b/cpukit/rtems/include/rtems/rtems/intr.h
@@ -180,6 +180,16 @@ typedef ISR_lock_Context rtems_interrupt_lock_context;
_ISR_lock_Initialize( _lock )
/**
+ * @brief Destroys an interrupt lock.
+ *
+ * Concurrent destruction leads to unpredictable results.
+ *
+ * @param[in,out] _lock The interrupt lock control.
+ */
+#define rtems_interrupt_lock_destroy( _lock ) \
+ _ISR_lock_Destroy( _lock )
+
+/**
* @brief Acquires an interrupt lock.
*
* Interrupts will be disabled. On SMP configurations this function acquires
diff --git a/cpukit/score/include/rtems/score/isrlock.h b/cpukit/score/include/rtems/score/isrlock.h
index e118475968..27e4aadffa 100644
--- a/cpukit/score/include/rtems/score/isrlock.h
+++ b/cpukit/score/include/rtems/score/isrlock.h
@@ -95,6 +95,22 @@ static inline void _ISR_lock_Initialize( ISR_lock_Control *lock )
}
/**
+ * @brief Destroys an ISR lock.
+ *
+ * Concurrent destruction leads to unpredictable results.
+ *
+ * @param[in,out] lock The ISR lock control.
+ */
+static inline void _ISR_lock_Destroy( ISR_lock_Control *lock )
+{
+#if defined( RTEMS_SMP )
+ _SMP_lock_Destroy( &lock->lock );
+#else
+ (void) lock;
+#endif
+}
+
+/**
* @brief Acquires an ISR lock.
*
* Interrupts will be disabled. On SMP configurations this function acquires
diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h
index 101aa0a6a1..288fd454da 100644
--- a/cpukit/score/include/rtems/score/smplock.h
+++ b/cpukit/score/include/rtems/score/smplock.h
@@ -64,11 +64,11 @@ typedef struct {
{ ATOMIC_INITIALIZER_UINT( 0U ), ATOMIC_INITIALIZER_UINT( 0U ) }
/**
- * @brief Initializes an SMP ticket lock control.
+ * @brief Initializes an SMP ticket lock.
*
* Concurrent initialization leads to unpredictable results.
*
- * @param[out] lock The SMP ticket lock control.
+ * @param[in,out] lock The SMP ticket lock control.
*/
static inline void _SMP_ticket_lock_Initialize( SMP_ticket_lock_Control *lock )
{
@@ -77,6 +77,18 @@ static inline void _SMP_ticket_lock_Initialize( SMP_ticket_lock_Control *lock )
}
/**
+ * @brief Destroys an SMP ticket lock.
+ *
+ * Concurrent destruction leads to unpredictable results.
+ *
+ * @param[in,out] lock The SMP ticket lock control.
+ */
+static inline void _SMP_ticket_lock_Destroy( SMP_ticket_lock_Control *lock )
+{
+ (void) lock;
+}
+
+/**
* @brief Acquires an SMP ticket lock.
*
* This function will not disable interrupts. The caller must ensure that the
@@ -131,11 +143,11 @@ typedef struct {
#define SMP_LOCK_INITIALIZER { SMP_TICKET_LOCK_INITIALIZER }
/**
- * @brief Initializes an SMP lock control.
+ * @brief Initializes an SMP lock.
*
* Concurrent initialization leads to unpredictable results.
*
- * @param[out] lock The SMP lock control.
+ * @param[in,out] lock The SMP lock control.
*/
static inline void _SMP_lock_Initialize( SMP_lock_Control *lock )
{
@@ -143,6 +155,18 @@ static inline void _SMP_lock_Initialize( SMP_lock_Control *lock )
}
/**
+ * @brief Destroys an SMP lock.
+ *
+ * Concurrent destruction leads to unpredictable results.
+ *
+ * @param[in,out] lock The SMP lock control.
+ */
+static inline void _SMP_lock_Destroy( SMP_lock_Control *lock )
+{
+ _SMP_ticket_lock_Destroy( &lock->ticket_lock );
+}
+
+/**
* @brief Acquires an SMP lock.
*
* This function will not disable interrupts. The caller must ensure that the
diff --git a/testsuites/smptests/smplock01/init.c b/testsuites/smptests/smplock01/init.c
index d67d7bc07e..7c536c304c 100644
--- a/testsuites/smptests/smplock01/init.c
+++ b/testsuites/smptests/smplock01/init.c
@@ -138,15 +138,19 @@ static void test_2_body(
)
{
unsigned long counter = 0;
- SMP_lock_Control lock = SMP_LOCK_INITIALIZER;
+ SMP_lock_Control lock;
SMP_lock_Context lock_context;
+ _SMP_lock_Initialize(&lock);
+
while (assert_state(ctx, START_TEST)) {
_SMP_lock_Acquire(&lock, &lock_context);
_SMP_lock_Release(&lock, &lock_context);
++counter;
}
+ _SMP_lock_Destroy(&lock);
+
ctx->test_counter[test][cpu_self] = counter;
}
@@ -159,9 +163,11 @@ static void test_3_body(
)
{
unsigned long counter = 0;
- SMP_lock_Control lock = SMP_LOCK_INITIALIZER;
+ SMP_lock_Control lock;
SMP_lock_Context lock_context;
+ _SMP_lock_Initialize(&lock);
+
while (assert_state(ctx, START_TEST)) {
_SMP_lock_Acquire(&lock, &lock_context);
@@ -172,6 +178,8 @@ static void test_3_body(
++counter;
}
+ _SMP_lock_Destroy(&lock);
+
ctx->test_counter[test][cpu_self] = counter;
}
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index cd49ae26f8..4a3e08c862 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -178,6 +178,9 @@ static void test_isr_locks( void )
_ISR_lock_Release( &lock, &lock_context );
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
+
+ _ISR_lock_Destroy( &lock );
+ _ISR_lock_Destroy( &initialized );
}
static rtems_mode get_interrupt_level( void )
@@ -212,6 +215,9 @@ static void test_interrupt_locks( void )
rtems_interrupt_lock_release_isr( &lock, &lock_context );
rtems_test_assert( normal_interrupt_level == get_interrupt_level() );
+
+ rtems_interrupt_lock_destroy( &lock );
+ rtems_interrupt_lock_destroy( &initialized );
}
void test_interrupt_inline(void)
diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c
index faccbd4084..4c0c3c3f61 100644
--- a/testsuites/sptests/spcache01/init.c
+++ b/testsuites/sptests/spcache01/init.c
@@ -90,6 +90,7 @@ static void test_data_flush_and_invalidate(void)
}
rtems_interrupt_lock_release(&lock, &lock_context);
+ rtems_interrupt_lock_destroy(&lock);
printf(
"data cache operations by line passed the test (%s cache detected)\n",
@@ -364,6 +365,8 @@ static void test_timing(void)
d[1],
d[2]
);
+
+ rtems_interrupt_lock_destroy(&lock);
}
static void Init(rtems_task_argument arg)
diff --git a/testsuites/sptests/spnsext01/init.c b/testsuites/sptests/spnsext01/init.c
index 788ba0b187..b445679fb9 100644
--- a/testsuites/sptests/spnsext01/init.c
+++ b/testsuites/sptests/spnsext01/init.c
@@ -65,6 +65,7 @@ static rtems_task Init(rtems_task_argument argument)
uptime = new_uptime;
}
rtems_interrupt_lock_release(&lock, &lock_context);
+ rtems_interrupt_lock_destroy(&lock);
puts("*** END OF TEST NANO SECONDS EXTENSION 1 ***");
diff --git a/testsuites/tmtests/tmcontext01/init.c b/testsuites/tmtests/tmcontext01/init.c
index 130952b4e8..bd047a2ccf 100644
--- a/testsuites/tmtests/tmcontext01/init.c
+++ b/testsuites/tmtests/tmcontext01/init.c
@@ -129,7 +129,7 @@ static void sort_t(void)
static void test_by_function_level(int fl, bool dirty)
{
- rtems_interrupt_lock lock = RTEMS_INTERRUPT_LOCK_INITIALIZER;
+ rtems_interrupt_lock lock;
rtems_interrupt_lock_context lock_context;
int s;
uint64_t min;
@@ -138,6 +138,7 @@ static void test_by_function_level(int fl, bool dirty)
uint64_t q3;
uint64_t max;
+ rtems_interrupt_lock_initialize(&lock);
rtems_interrupt_lock_acquire(&lock, &lock_context);
for (s = 0; s < SAMPLES; ++s) {
@@ -145,6 +146,7 @@ static void test_by_function_level(int fl, bool dirty)
}
rtems_interrupt_lock_release(&lock, &lock_context);
+ rtems_interrupt_lock_destroy(&lock);
sort_t();