[PATCH] score: _Thread_queue_Enqueue_with_handler()

Joel Sherrill joel.sherrill at OARcorp.com
Thu Aug 22 13:29:14 UTC 2013


This looks ok to commit.

If it compiles and didn't add any warnings in code or Doxygen,
I don't see what else could be wrong.

On 8/22/2013 8:21 AM, Sebastian Huber wrote:
> Add thread parameter to _Thread_queue_Enqueue_with_handler() to avoid
> access to global _Thread_Executing.
> ---
>   cpukit/posix/src/condwaitsupp.c                |    2 +-
>   cpukit/posix/src/pthreadjoin.c                 |    6 +++++-
>   cpukit/posix/src/sigtimedwait.c                |    2 +-
>   cpukit/rtems/src/regiongetsegment.c            |    6 +++++-
>   cpukit/score/include/rtems/score/coresemimpl.h |    2 +-
>   cpukit/score/include/rtems/score/threadqimpl.h |   11 +++++++----
>   cpukit/score/src/corebarrierwait.c             |    2 +-
>   cpukit/score/src/coremsgseize.c                |    2 +-
>   cpukit/score/src/coremsgsubmit.c               |    6 +++++-
>   cpukit/score/src/coremutexseize.c              |    2 +-
>   cpukit/score/src/corerwlockobtainread.c        |    1 +
>   cpukit/score/src/corerwlockobtainwrite.c       |    1 +
>   cpukit/score/src/coresemseize.c                |    2 +-
>   cpukit/score/src/mpci.c                        |   22 ++++++++++++++--------
>   cpukit/score/src/threadqenqueue.c              |    4 +---
>   15 files changed, 46 insertions(+), 25 deletions(-)
>
> diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
> index 86ad3aa..a13d4f7 100644
> --- a/cpukit/posix/src/condwaitsupp.c
> +++ b/cpukit/posix/src/condwaitsupp.c
> @@ -75,7 +75,7 @@ int _POSIX_Condition_variables_Wait_support(
>           executing->Wait.queue       = &the_cond->Wait_queue;
>           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 );
>   
> diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
> index f7a9d45..6b562ec 100644
> --- a/cpukit/posix/src/pthreadjoin.c
> +++ b/cpukit/posix/src/pthreadjoin.c
> @@ -71,7 +71,11 @@ on_EINTR:
>         } else {
>           executing->Wait.return_argument = &return_pointer;
>           _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 );
>   
> diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
> index ba24c85..65454ac 100644
> --- a/cpukit/posix/src/sigtimedwait.c
> +++ b/cpukit/posix/src/sigtimedwait.c
> @@ -157,7 +157,7 @@ int sigtimedwait(
>       executing->Wait.return_argument = the_info;
>       _Thread_queue_Enter_critical_section( &_POSIX_signals_Wait_queue );
>       _ISR_Enable( level );
> -    _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, interval );
> +    _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, executing, interval );
>     _Thread_Enable_dispatch();
>   
>     /*
> diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c
> index 8fea5f8..52fac44 100644
> --- a/cpukit/rtems/src/regiongetsegment.c
> +++ b/cpukit/rtems/src/regiongetsegment.c
> @@ -85,7 +85,11 @@ rtems_status_code rtems_region_get_segment(
>   
>               _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 );
>   
> diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
> index 4c3c8be..7f12a98 100644
> --- a/cpukit/score/include/rtems/score/coresemimpl.h
> +++ b/cpukit/score/include/rtems/score/coresemimpl.h
> @@ -241,7 +241,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
>     executing->Wait.id             = id;
>     _ISR_Enable( level );
>   
> -  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
> +  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
>     _Thread_Enable_dispatch();
>   }
>   
> diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
> index 3d801c8..dde9b39 100644
> --- a/cpukit/score/include/rtems/score/threadqimpl.h
> +++ b/cpukit/score/include/rtems/score/threadqimpl.h
> @@ -83,9 +83,10 @@ Thread_Control *_Thread_queue_Dequeue(
>    *  This routine enqueues the currently executing thread on
>    *  the_thread_queue with an optional timeout.
>    */
> -#define _Thread_queue_Enqueue( _the_thread_queue, _timeout ) \
> +#define _Thread_queue_Enqueue( _the_thread, _the_thread_queue, _timeout ) \
>     _Thread_queue_Enqueue_with_handler( \
>       _the_thread_queue, \
> +    _the_thread, \
>       _timeout, \
>       _Thread_queue_Timeout )
>   
> @@ -96,15 +97,17 @@ Thread_Control *_Thread_queue_Dequeue(
>    *  starts a timeout timer.
>    *
>    *  @param[in] the_thread_queue pointer to threadq
> + *  @param[in] the_thread the thread to enqueue
>    *  @param[in] timeout interval to wait
>    *
>    *  - INTERRUPT LATENCY:
>    *    + single case
>    */
>   void _Thread_queue_Enqueue_with_handler(
> -  Thread_queue_Control*        the_thread_queue,
> -  Watchdog_Interval            timeout,
> -  Thread_queue_Timeout_callout handler
> +  Thread_queue_Control         *the_thread_queue,
> +  Thread_Control               *the_thread,
> +  Watchdog_Interval             timeout,
> +  Thread_queue_Timeout_callout  handler
>   );
>   
>   /**
> diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c
> index aa9face..97edf13 100644
> --- a/cpukit/score/src/corebarrierwait.c
> +++ b/cpukit/score/src/corebarrierwait.c
> @@ -51,5 +51,5 @@ void _CORE_barrier_Wait(
>     executing->Wait.id             = id;
>     _ISR_Enable( level );
>   
> -  _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout );
> +  _Thread_queue_Enqueue( &the_barrier->Wait_queue, executing, timeout );
>   }
> diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
> index b3280bf..11d83ee 100644
> --- a/cpukit/score/src/coremsgseize.c
> +++ b/cpukit/score/src/coremsgseize.c
> @@ -121,5 +121,5 @@ void _CORE_message_queue_Seize(
>     /* Wait.count will be filled in with the message priority */
>     _ISR_Enable( level );
>   
> -  _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
> +  _Thread_queue_Enqueue( &the_message_queue->Wait_queue, executing, timeout );
>   }
> diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
> index b0b4833..3fc4f4c 100644
> --- a/cpukit/score/src/coremsgsubmit.c
> +++ b/cpukit/score/src/coremsgsubmit.c
> @@ -130,7 +130,11 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
>         executing->Wait.count = submit_type;
>         _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;
> diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
> index 2cab59e..283029d 100644
> --- a/cpukit/score/src/coremutexseize.c
> +++ b/cpukit/score/src/coremutexseize.c
> @@ -65,7 +65,7 @@ void _CORE_mutex_Seize_interrupt_blocking(
>     }
>   
>     the_mutex->blocked_count++;
> -  _Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
> +  _Thread_queue_Enqueue( &the_mutex->Wait_queue, executing, timeout );
>   
>     _Thread_Enable_dispatch();
>   }
> diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
> index ca9a214..cfba5cf 100644
> --- a/cpukit/score/src/corerwlockobtainread.c
> +++ b/cpukit/score/src/corerwlockobtainread.c
> @@ -86,6 +86,7 @@ void _CORE_RWLock_Obtain_for_reading(
>   
>       _Thread_queue_Enqueue_with_handler(
>          &the_rwlock->Wait_queue,
> +       executing,
>          timeout,
>          _CORE_RWLock_Timeout
>       );
> diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
> index e5f3e73..54c41d9 100644
> --- a/cpukit/score/src/corerwlockobtainwrite.c
> +++ b/cpukit/score/src/corerwlockobtainwrite.c
> @@ -76,6 +76,7 @@ void _CORE_RWLock_Obtain_for_writing(
>   
>       _Thread_queue_Enqueue_with_handler(
>          &the_rwlock->Wait_queue,
> +       executing,
>          timeout,
>          _CORE_RWLock_Timeout
>       );
> diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c
> index cde444b..2cbfb47 100644
> --- a/cpukit/score/src/coresemseize.c
> +++ b/cpukit/score/src/coresemseize.c
> @@ -63,6 +63,6 @@ void _CORE_semaphore_Seize(
>     executing->Wait.queue = &the_semaphore->Wait_queue;
>     executing->Wait.id    = id;
>     _ISR_Enable( level );
> -  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
> +  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
>   }
>   #endif
> diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
> index c8cf6bd..bc28994 100644
> --- a/cpukit/score/src/mpci.c
> +++ b/cpukit/score/src/mpci.c
> @@ -190,14 +190,16 @@ uint32_t   _MPCI_Send_request_packet (
>     States_Control      extra_state
>   )
>   {
> -  the_packet->source_tid      = _Thread_Executing->Object.id;
> -  the_packet->source_priority = _Thread_Executing->current_priority;
> +  Thread_Control *executing = _Thread_Executing;
> +
> +  the_packet->source_tid      = executing->Object.id;
> +  the_packet->source_priority = executing->current_priority;
>     the_packet->to_convert =
>        ( 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();
>   
> @@ -212,14 +214,18 @@ uint32_t   _MPCI_Send_request_packet (
>       if (the_packet->timeout == MPCI_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 =
> -      _States_Set( extra_state, _Thread_Executing->current_state );
> +    executing->current_state =
> +      _States_Set( extra_state, executing->current_state );
>   
>     _Thread_Enable_dispatch();
>   
> -  return _Thread_Executing->Wait.return_code;
> +  return executing->Wait.return_code;
>   }
>   
>   void _MPCI_Send_response_packet (
> diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
> index 92d5546..54f85f8 100644
> --- a/cpukit/score/src/threadqenqueue.c
> +++ b/cpukit/score/src/threadqenqueue.c
> @@ -28,11 +28,11 @@
>   
>   void _Thread_queue_Enqueue_with_handler(
>     Thread_queue_Control         *the_thread_queue,
> +  Thread_Control               *the_thread,
>     Watchdog_Interval             timeout,
>     Thread_queue_Timeout_callout  handler
>   )
>   {
> -  Thread_Control                   *the_thread;
>     ISR_Level                         level;
>     Thread_blocking_operation_States  sync_state;
>     Thread_blocking_operation_States (*enqueue_p)(
> @@ -41,8 +41,6 @@ void _Thread_queue_Enqueue_with_handler(
>       ISR_Level *
>     );
>   
> -  the_thread = _Thread_Executing;
> -
>   #if defined(RTEMS_MULTIPROCESSING)
>     if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
>       the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list