forked from Imagelibrary/rtems
score: Add function to destroy SMP locks
This commit is contained in:
@@ -445,6 +445,7 @@ rtems_termios_close (void *arg)
|
|||||||
if ((tty->device.pollRead == NULL) ||
|
if ((tty->device.pollRead == NULL) ||
|
||||||
(tty->device.outputUsesInterrupts == TERMIOS_TASK_DRIVEN))
|
(tty->device.outputUsesInterrupts == TERMIOS_TASK_DRIVEN))
|
||||||
rtems_semaphore_delete (tty->rawInBuf.Semaphore);
|
rtems_semaphore_delete (tty->rawInBuf.Semaphore);
|
||||||
|
rtems_interrupt_lock_destroy (&tty->interrupt_lock);
|
||||||
free (tty->rawInBuf.theBuf);
|
free (tty->rawInBuf.theBuf);
|
||||||
free (tty->rawOutBuf.theBuf);
|
free (tty->rawOutBuf.theBuf);
|
||||||
free (tty->cbuf);
|
free (tty->cbuf);
|
||||||
|
|||||||
@@ -179,6 +179,16 @@ typedef ISR_lock_Context rtems_interrupt_lock_context;
|
|||||||
#define rtems_interrupt_lock_initialize( _lock ) \
|
#define rtems_interrupt_lock_initialize( _lock ) \
|
||||||
_ISR_lock_Initialize( _lock )
|
_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.
|
* @brief Acquires an interrupt lock.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -94,6 +94,22 @@ static inline void _ISR_lock_Initialize( ISR_lock_Control *lock )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @brief Acquires an ISR lock.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ typedef struct {
|
|||||||
{ ATOMIC_INITIALIZER_UINT( 0U ), ATOMIC_INITIALIZER_UINT( 0U ) }
|
{ 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.
|
* 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 )
|
static inline void _SMP_ticket_lock_Initialize( SMP_ticket_lock_Control *lock )
|
||||||
{
|
{
|
||||||
@@ -76,6 +76,18 @@ static inline void _SMP_ticket_lock_Initialize( SMP_ticket_lock_Control *lock )
|
|||||||
_Atomic_Init_uint( &lock->now_serving, 0U );
|
_Atomic_Init_uint( &lock->now_serving, 0U );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @brief Acquires an SMP ticket lock.
|
||||||
*
|
*
|
||||||
@@ -131,17 +143,29 @@ typedef struct {
|
|||||||
#define SMP_LOCK_INITIALIZER { SMP_TICKET_LOCK_INITIALIZER }
|
#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.
|
* 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 )
|
static inline void _SMP_lock_Initialize( SMP_lock_Control *lock )
|
||||||
{
|
{
|
||||||
_SMP_ticket_lock_Initialize( &lock->ticket_lock );
|
_SMP_ticket_lock_Initialize( &lock->ticket_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.
|
* @brief Acquires an SMP lock.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -138,15 +138,19 @@ static void test_2_body(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned long counter = 0;
|
unsigned long counter = 0;
|
||||||
SMP_lock_Control lock = SMP_LOCK_INITIALIZER;
|
SMP_lock_Control lock;
|
||||||
SMP_lock_Context lock_context;
|
SMP_lock_Context lock_context;
|
||||||
|
|
||||||
|
_SMP_lock_Initialize(&lock);
|
||||||
|
|
||||||
while (assert_state(ctx, START_TEST)) {
|
while (assert_state(ctx, START_TEST)) {
|
||||||
_SMP_lock_Acquire(&lock, &lock_context);
|
_SMP_lock_Acquire(&lock, &lock_context);
|
||||||
_SMP_lock_Release(&lock, &lock_context);
|
_SMP_lock_Release(&lock, &lock_context);
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_SMP_lock_Destroy(&lock);
|
||||||
|
|
||||||
ctx->test_counter[test][cpu_self] = counter;
|
ctx->test_counter[test][cpu_self] = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,9 +163,11 @@ static void test_3_body(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned long counter = 0;
|
unsigned long counter = 0;
|
||||||
SMP_lock_Control lock = SMP_LOCK_INITIALIZER;
|
SMP_lock_Control lock;
|
||||||
SMP_lock_Context lock_context;
|
SMP_lock_Context lock_context;
|
||||||
|
|
||||||
|
_SMP_lock_Initialize(&lock);
|
||||||
|
|
||||||
while (assert_state(ctx, START_TEST)) {
|
while (assert_state(ctx, START_TEST)) {
|
||||||
_SMP_lock_Acquire(&lock, &lock_context);
|
_SMP_lock_Acquire(&lock, &lock_context);
|
||||||
|
|
||||||
@@ -172,6 +178,8 @@ static void test_3_body(
|
|||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_SMP_lock_Destroy(&lock);
|
||||||
|
|
||||||
ctx->test_counter[test][cpu_self] = counter;
|
ctx->test_counter[test][cpu_self] = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ static void test_isr_locks( void )
|
|||||||
_ISR_lock_Release( &lock, &lock_context );
|
_ISR_lock_Release( &lock, &lock_context );
|
||||||
|
|
||||||
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
||||||
|
|
||||||
|
_ISR_lock_Destroy( &lock );
|
||||||
|
_ISR_lock_Destroy( &initialized );
|
||||||
}
|
}
|
||||||
|
|
||||||
static rtems_mode get_interrupt_level( void )
|
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_interrupt_lock_release_isr( &lock, &lock_context );
|
||||||
|
|
||||||
rtems_test_assert( normal_interrupt_level == get_interrupt_level() );
|
rtems_test_assert( normal_interrupt_level == get_interrupt_level() );
|
||||||
|
|
||||||
|
rtems_interrupt_lock_destroy( &lock );
|
||||||
|
rtems_interrupt_lock_destroy( &initialized );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_interrupt_inline(void)
|
void test_interrupt_inline(void)
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ static void test_data_flush_and_invalidate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rtems_interrupt_lock_release(&lock, &lock_context);
|
rtems_interrupt_lock_release(&lock, &lock_context);
|
||||||
|
rtems_interrupt_lock_destroy(&lock);
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"data cache operations by line passed the test (%s cache detected)\n",
|
"data cache operations by line passed the test (%s cache detected)\n",
|
||||||
@@ -364,6 +365,8 @@ static void test_timing(void)
|
|||||||
d[1],
|
d[1],
|
||||||
d[2]
|
d[2]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
rtems_interrupt_lock_destroy(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Init(rtems_task_argument arg)
|
static void Init(rtems_task_argument arg)
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ static rtems_task Init(rtems_task_argument argument)
|
|||||||
uptime = new_uptime;
|
uptime = new_uptime;
|
||||||
}
|
}
|
||||||
rtems_interrupt_lock_release(&lock, &lock_context);
|
rtems_interrupt_lock_release(&lock, &lock_context);
|
||||||
|
rtems_interrupt_lock_destroy(&lock);
|
||||||
|
|
||||||
puts("*** END OF TEST NANO SECONDS EXTENSION 1 ***");
|
puts("*** END OF TEST NANO SECONDS EXTENSION 1 ***");
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ static void sort_t(void)
|
|||||||
|
|
||||||
static void test_by_function_level(int fl, bool dirty)
|
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;
|
rtems_interrupt_lock_context lock_context;
|
||||||
int s;
|
int s;
|
||||||
uint64_t min;
|
uint64_t min;
|
||||||
@@ -138,6 +138,7 @@ static void test_by_function_level(int fl, bool dirty)
|
|||||||
uint64_t q3;
|
uint64_t q3;
|
||||||
uint64_t max;
|
uint64_t max;
|
||||||
|
|
||||||
|
rtems_interrupt_lock_initialize(&lock);
|
||||||
rtems_interrupt_lock_acquire(&lock, &lock_context);
|
rtems_interrupt_lock_acquire(&lock, &lock_context);
|
||||||
|
|
||||||
for (s = 0; s < SAMPLES; ++s) {
|
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_release(&lock, &lock_context);
|
||||||
|
rtems_interrupt_lock_destroy(&lock);
|
||||||
|
|
||||||
sort_t();
|
sort_t();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user