From cc366ec8c9ecaab838a745175a0d53a7a5db437e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 24 Apr 2015 12:02:20 +0200 Subject: score: New thread queue implementation Use thread wait flags for synchronization. The enqueue operation is now part of the initial critical section. This is the key change and enables fine grained locking on SMP for objects using a thread queue like semaphores and message queues. Update #2273. --- testsuites/sptests/spintrcritical09/init.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'testsuites/sptests/spintrcritical09') diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c index 0e38351d43..cc119e88c1 100644 --- a/testsuites/sptests/spintrcritical09/init.c +++ b/testsuites/sptests/spintrcritical09/init.c @@ -14,28 +14,22 @@ #include #include -#include +#include #include const char rtems_test_name[] = "SPINTRCRITICAL 9"; +static Thread_Control *thread; + static rtems_id Semaphore; -static bool case_hit = false; -static Thread_blocking_operation_States getState(void) +static bool case_hit; + +static bool is_interrupt_timeout(void) { - Objects_Locations location; - Semaphore_Control *sem; - - sem = (Semaphore_Control *)_Objects_Get( - &_Semaphore_Information, Semaphore, &location ); - if ( location != OBJECTS_LOCAL ) { - puts( "Bad object lookup" ); - rtems_test_exit(0); - } - _Thread_Unnest_dispatch(); + Thread_Wait_flags flags = _Thread_Wait_flags_get( thread ); - return sem->Core_control.semaphore.Wait_queue.sync_state; + return flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN ); } static rtems_timer_service_routine test_release_from_isr( @@ -50,14 +44,14 @@ static rtems_timer_service_routine test_release_from_isr( if ( watchdog->delta_interval == 0 - && watchdog->routine == _Thread_queue_Timeout + && watchdog->routine == _Thread_Timeout ) { Watchdog_States state = _Watchdog_Remove_ticks( watchdog ); rtems_test_assert( state == WATCHDOG_ACTIVE ); (*watchdog->routine)( watchdog->id, watchdog->user_data ); - if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) { + if ( is_interrupt_timeout() ) { case_hit = true; } } @@ -81,6 +75,8 @@ static rtems_task Init( TEST_BEGIN(); + thread = _Thread_Get_executing(); + puts( "Init - Test may not be able to detect case is hit reliably" ); puts( "Init - Trying to generate timeout from ISR while blocking" ); sc = rtems_semaphore_create( -- cgit v1.2.3