score: _Thread_queue_Enqueue_with_handler()

Add thread parameter to _Thread_queue_Enqueue_with_handler() to avoid
access to global _Thread_Executing.
This commit is contained in:
Sebastian Huber
2013-08-22 15:20:06 +02:00
parent f4804efa50
commit 07332ae4db
15 changed files with 46 additions and 25 deletions

View File

@@ -75,7 +75,7 @@ int _POSIX_Condition_variables_Wait_support(
executing->Wait.queue = &the_cond->Wait_queue; executing->Wait.queue = &the_cond->Wait_queue;
executing->Wait.id = *cond; executing->Wait.id = *cond;
_Thread_queue_Enqueue( &the_cond->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_cond->Wait_queue, executing, timeout );
_Objects_Put( &the_cond->Object ); _Objects_Put( &the_cond->Object );

View File

@@ -71,7 +71,11 @@ on_EINTR:
} else { } else {
executing->Wait.return_argument = &return_pointer; executing->Wait.return_argument = &return_pointer;
_Thread_queue_Enter_critical_section( &api->Join_List ); _Thread_queue_Enter_critical_section( &api->Join_List );
_Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT ); _Thread_queue_Enqueue(
&api->Join_List,
executing,
WATCHDOG_NO_TIMEOUT
);
} }
_Objects_Put( &the_thread->Object ); _Objects_Put( &the_thread->Object );

View File

@@ -157,7 +157,7 @@ int sigtimedwait(
executing->Wait.return_argument = the_info; executing->Wait.return_argument = the_info;
_Thread_queue_Enter_critical_section( &_POSIX_signals_Wait_queue ); _Thread_queue_Enter_critical_section( &_POSIX_signals_Wait_queue );
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, interval ); _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, executing, interval );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
/* /*

View File

@@ -85,7 +85,11 @@ rtems_status_code rtems_region_get_segment(
_Thread_queue_Enter_critical_section( &the_region->Wait_queue ); _Thread_queue_Enter_critical_section( &the_region->Wait_queue );
_Thread_queue_Enqueue( &the_region->Wait_queue, timeout ); _Thread_queue_Enqueue(
&the_region->Wait_queue,
executing,
timeout
);
_Objects_Put( &the_region->Object ); _Objects_Put( &the_region->Object );

View File

@@ -241,7 +241,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
executing->Wait.id = id; executing->Wait.id = id;
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
} }

View File

@@ -83,9 +83,10 @@ Thread_Control *_Thread_queue_Dequeue(
* This routine enqueues the currently executing thread on * This routine enqueues the currently executing thread on
* the_thread_queue with an optional timeout. * the_thread_queue with an optional timeout.
*/ */
#define _Thread_queue_Enqueue( _the_thread_queue, _timeout ) \ #define _Thread_queue_Enqueue( _the_thread_queue, _the_thread, _timeout ) \
_Thread_queue_Enqueue_with_handler( \ _Thread_queue_Enqueue_with_handler( \
_the_thread_queue, \ _the_thread_queue, \
_the_thread, \
_timeout, \ _timeout, \
_Thread_queue_Timeout ) _Thread_queue_Timeout )
@@ -96,15 +97,17 @@ Thread_Control *_Thread_queue_Dequeue(
* starts a timeout timer. * starts a timeout timer.
* *
* @param[in] the_thread_queue pointer to threadq * @param[in] the_thread_queue pointer to threadq
* @param[in] the_thread the thread to enqueue
* @param[in] timeout interval to wait * @param[in] timeout interval to wait
* *
* - INTERRUPT LATENCY: * - INTERRUPT LATENCY:
* + single case * + single case
*/ */
void _Thread_queue_Enqueue_with_handler( void _Thread_queue_Enqueue_with_handler(
Thread_queue_Control* the_thread_queue, Thread_queue_Control *the_thread_queue,
Watchdog_Interval timeout, Thread_Control *the_thread,
Thread_queue_Timeout_callout handler Watchdog_Interval timeout,
Thread_queue_Timeout_callout handler
); );
/** /**

View File

@@ -51,5 +51,5 @@ void _CORE_barrier_Wait(
executing->Wait.id = id; executing->Wait.id = id;
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_barrier->Wait_queue, executing, timeout );
} }

View File

@@ -121,5 +121,5 @@ void _CORE_message_queue_Seize(
/* Wait.count will be filled in with the message priority */ /* Wait.count will be filled in with the message priority */
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_message_queue->Wait_queue, executing, timeout );
} }

View File

@@ -130,7 +130,11 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
executing->Wait.count = submit_type; executing->Wait.count = submit_type;
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout ); _Thread_queue_Enqueue(
&the_message_queue->Wait_queue,
executing,
timeout
);
} }
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT; return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;

View File

@@ -65,7 +65,7 @@ void _CORE_mutex_Seize_interrupt_blocking(
} }
the_mutex->blocked_count++; the_mutex->blocked_count++;
_Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_mutex->Wait_queue, executing, timeout );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
} }

View File

@@ -86,6 +86,7 @@ void _CORE_RWLock_Obtain_for_reading(
_Thread_queue_Enqueue_with_handler( _Thread_queue_Enqueue_with_handler(
&the_rwlock->Wait_queue, &the_rwlock->Wait_queue,
executing,
timeout, timeout,
_CORE_RWLock_Timeout _CORE_RWLock_Timeout
); );

View File

@@ -76,6 +76,7 @@ void _CORE_RWLock_Obtain_for_writing(
_Thread_queue_Enqueue_with_handler( _Thread_queue_Enqueue_with_handler(
&the_rwlock->Wait_queue, &the_rwlock->Wait_queue,
executing,
timeout, timeout,
_CORE_RWLock_Timeout _CORE_RWLock_Timeout
); );

View File

@@ -63,6 +63,6 @@ void _CORE_semaphore_Seize(
executing->Wait.queue = &the_semaphore->Wait_queue; executing->Wait.queue = &the_semaphore->Wait_queue;
executing->Wait.id = id; executing->Wait.id = id;
_ISR_Enable( level ); _ISR_Enable( level );
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); _Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
} }
#endif #endif

View File

@@ -190,14 +190,16 @@ uint32_t _MPCI_Send_request_packet (
States_Control extra_state States_Control extra_state
) )
{ {
the_packet->source_tid = _Thread_Executing->Object.id; Thread_Control *executing = _Thread_Executing;
the_packet->source_priority = _Thread_Executing->current_priority;
the_packet->source_tid = executing->Object.id;
the_packet->source_priority = executing->current_priority;
the_packet->to_convert = the_packet->to_convert =
( the_packet->to_convert - sizeof(MP_packet_Prefix) ) / sizeof(uint32_t); ( the_packet->to_convert - sizeof(MP_packet_Prefix) ) / sizeof(uint32_t);
_Thread_Executing->Wait.id = the_packet->id; executing->Wait.id = the_packet->id;
_Thread_Executing->Wait.queue = &_MPCI_Remote_blocked_threads; executing->Wait.queue = &_MPCI_Remote_blocked_threads;
_Thread_Disable_dispatch(); _Thread_Disable_dispatch();
@@ -212,14 +214,18 @@ uint32_t _MPCI_Send_request_packet (
if (the_packet->timeout == MPCI_DEFAULT_TIMEOUT) if (the_packet->timeout == MPCI_DEFAULT_TIMEOUT)
the_packet->timeout = _MPCI_table->default_timeout; the_packet->timeout = _MPCI_table->default_timeout;
_Thread_queue_Enqueue( &_MPCI_Remote_blocked_threads, the_packet->timeout ); _Thread_queue_Enqueue(
&_MPCI_Remote_blocked_threads,
executing,
the_packet->timeout
);
_Thread_Executing->current_state = executing->current_state =
_States_Set( extra_state, _Thread_Executing->current_state ); _States_Set( extra_state, executing->current_state );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return _Thread_Executing->Wait.return_code; return executing->Wait.return_code;
} }
void _MPCI_Send_response_packet ( void _MPCI_Send_response_packet (

View File

@@ -28,11 +28,11 @@
void _Thread_queue_Enqueue_with_handler( void _Thread_queue_Enqueue_with_handler(
Thread_queue_Control *the_thread_queue, Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
Watchdog_Interval timeout, Watchdog_Interval timeout,
Thread_queue_Timeout_callout handler Thread_queue_Timeout_callout handler
) )
{ {
Thread_Control *the_thread;
ISR_Level level; ISR_Level level;
Thread_blocking_operation_States sync_state; Thread_blocking_operation_States sync_state;
Thread_blocking_operation_States (*enqueue_p)( Thread_blocking_operation_States (*enqueue_p)(
@@ -41,8 +41,6 @@ void _Thread_queue_Enqueue_with_handler(
ISR_Level * ISR_Level *
); );
the_thread = _Thread_Executing;
#if defined(RTEMS_MULTIPROCESSING) #if defined(RTEMS_MULTIPROCESSING)
if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state ); the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );