Changeset f23d470 in rtems


Ignore:
Timestamp:
Jun 9, 2016, 3:33:15 PM (3 years ago)
Author:
Gedare Bloom <gedare@…>
Branches:
master
Children:
6e98ea91
Parents:
7f616dd
git-author:
Gedare Bloom <gedare@…> (06/09/16 15:33:15)
git-committer:
Gedare Bloom <gedare@…> (07/25/16 16:44:47)
Message:

cpukit: Add and use Watchdog_Discipline.

Clock disciplines may be WATCHDOG_RELATIVE, WATCHDOG_ABSOLUTE,
or WATCHDOG_NO_TIMEOUT. A discipline of WATCHDOG_RELATIVE with
a timeout of WATCHDOG_NO_TIMEOUT is equivalent to a discipline
of WATCHDOG_NO_TIMEOUT.

updates #2732

Location:
cpukit
Files:
47 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/rtems/rtems_glue.c

    r7f616dd rf23d470  
    377377        _Thread_queue_Context_initialize(&queue_context);
    378378        _ISR_lock_ISR_disable(&queue_context.Lock_context);
     379        _Thread_queue_Context_set_no_timeout( &queue_context );
    379380        status = _CORE_recursive_mutex_Seize (
    380381                &the_networkSemaphore->Core_control.Mutex.Recursive,
    381382                _Thread_Executing,
    382383                true,                   /* wait */
    383                 WATCHDOG_NO_TIMEOUT,    /* forever */
    384384                _CORE_recursive_mutex_Seize_nested,
    385385                &queue_context
  • cpukit/posix/src/condwaitsupp.c

    r7f616dd rf23d470  
    6969  if ( !already_timedout ) {
    7070    _Thread_queue_Context_set_expected_level( &queue_context, 2 );
     71    _Thread_queue_Context_set_timeout( &queue_context, timeout );
     72    _Thread_queue_Context_set_discipline( &queue_context, WATCHDOG_RELATIVE );
    7173    _Thread_queue_Enqueue_critical(
    7274      &the_cond->Wait_queue.Queue,
     
    7476      executing,
    7577      STATES_WAITING_FOR_CONDITION_VARIABLE,
    76       timeout,
    7778      &queue_context
    7879    );
  • cpukit/posix/src/mqueuerecvsupp.c

    r7f616dd rf23d470  
    9898   */
    9999  executing = _Thread_Executing;
     100  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    100101  status = _CORE_message_queue_Seize(
    101102    &the_mq->Message_queue,
     
    104105    &length_out,
    105106    do_wait,
    106     timeout,
    107107    &queue_context
    108108  );
  • cpukit/posix/src/mqueuesendsupp.c

    r7f616dd rf23d470  
    9393   */
    9494  executing = _Thread_Executing;
     95  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    9596  status = _CORE_message_queue_Submit(
    9697    &the_mq->Message_queue,
     
    100101    _POSIX_Message_queue_Priority_to_core( msg_prio ),
    101102    do_wait,
    102     timeout,
    103103    &queue_context
    104104  );
  • cpukit/posix/src/mutexlocksupp.c

    r7f616dd rf23d470  
    6464
    6565  executing = _Thread_Executing;
     66  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    6667
    6768  switch ( the_mutex->protocol ) {
     
    7172        executing,
    7273        wait,
    73         timeout,
    7474        _POSIX_Mutex_Lock_nested,
    7575        &queue_context
     
    8282        executing,
    8383        wait,
    84         timeout,
    8584        _POSIX_Mutex_Lock_nested,
    8685        &queue_context
     
    9392        executing,
    9493        wait,
    95         timeout,
    9694        _POSIX_Mutex_Lock_nested,
    9795        &queue_context
  • cpukit/posix/src/nanosleep.c

    r7f616dd rf23d470  
    9494    STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
    9595    ticks,
     96    WATCHDOG_RELATIVE,
    9697    1
    9798  );
  • cpukit/posix/src/pbarrierwait.c

    r7f616dd rf23d470  
    4242  }
    4343
     44  _Thread_queue_Context_set_no_timeout( &queue_context );
    4445  status = _CORE_barrier_Seize(
    4546    &the_barrier->Barrier,
    4647    _Thread_Executing,
    4748    true,
    48     WATCHDOG_NO_TIMEOUT,
    4949    &queue_context
    5050  );
  • cpukit/posix/src/prwlockrdlock.c

    r7f616dd rf23d470  
    3636  }
    3737
     38  _Thread_queue_Context_set_no_timeout( &queue_context );
    3839  status = _CORE_RWLock_Seize_for_reading(
    3940    &the_rwlock->RWLock,
    4041    _Thread_Executing,
    4142    true,                 /* we are willing to wait forever */
    42     0,
    4343    &queue_context
    4444  );
  • cpukit/posix/src/prwlocktimedrdlock.c

    r7f616dd rf23d470  
    5757  }
    5858
     59  _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
    5960  status = _CORE_RWLock_Seize_for_reading(
    6061    &the_rwlock->RWLock,
    6162    _Thread_Executing,
    6263    do_wait,
    63     ticks,
    6464    &queue_context
    6565  );
  • cpukit/posix/src/prwlocktimedwrlock.c

    r7f616dd rf23d470  
    5959  }
    6060
     61  _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
    6162  status = _CORE_RWLock_Seize_for_writing(
    6263    &the_rwlock->RWLock,
    6364    _Thread_Executing,
    6465    do_wait,
    65     ticks,
    6666    &queue_context
    6767  );
  • cpukit/posix/src/prwlocktryrdlock.c

    r7f616dd rf23d470  
    4040    _Thread_Executing,
    4141    false,                  /* do not wait for the rwlock */
    42     0,
    4342    &queue_context
    4443  );
  • cpukit/posix/src/prwlocktrywrlock.c

    r7f616dd rf23d470  
    4040    _Thread_Executing,
    4141    false,                 /* we are not willing to wait */
    42     0,
    4342    &queue_context
    4443  );
  • cpukit/posix/src/prwlockwrlock.c

    r7f616dd rf23d470  
    4040  }
    4141
     42  _Thread_queue_Context_set_no_timeout( &queue_context );
    4243  status = _CORE_RWLock_Seize_for_writing(
    4344    &the_rwlock->RWLock,
    4445    _Thread_Executing,
    4546    true,          /* do not timeout -- wait forever */
    46     0,
    4747    &queue_context
    4848  );
  • cpukit/posix/src/pthreadjoin.c

    r7f616dd rf23d470  
    4141  _Thread_queue_Context_initialize( &queue_context );
    4242  _Thread_queue_Context_set_expected_level( &queue_context, 1 );
     43  _Thread_queue_Context_set_no_timeout( &queue_context );
    4344  the_thread = _Thread_Get( thread, &queue_context.Lock_context );
    4445
  • cpukit/posix/src/semaphorewaitsupp.c

    r7f616dd rf23d470  
    4242  }
    4343
     44  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    4445  status = _CORE_semaphore_Seize(
    4546    &the_semaphore->Semaphore,
     
    4748    _Thread_Executing,
    4849    blocking,
    49     timeout,
    5050    &queue_context
    5151  );
  • cpukit/posix/src/sigtimedwait.c

    r7f616dd rf23d470  
    154154  executing->Wait.return_argument = the_info;
    155155  _Thread_queue_Context_set_expected_level( &queue_context, 1 );
     156  _Thread_queue_Context_set_relative_timeout( &queue_context, interval );
    156157  _Thread_queue_Enqueue_critical(
    157158    &_POSIX_signals_Wait_queue.Queue,
     
    159160    executing,
    160161    STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
    161     interval,
    162162    &queue_context
    163163  );
  • cpukit/rtems/src/barrierwait.c

    r7f616dd rf23d470  
    3939  }
    4040
     41  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    4142  status = _CORE_barrier_Seize(
    4243    &the_barrier->Barrier,
    4344    _Thread_Executing,
    4445    true,
    45     timeout,
    4646    &queue_context
    4747  );
  • cpukit/rtems/src/msgqreceive.c

    r7f616dd rf23d470  
    6262
    6363  executing = _Thread_Executing;
     64  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
    6465  status = _CORE_message_queue_Seize(
    6566    &the_message_queue->message_queue,
     
    6869    size,
    6970    !_Options_Is_no_wait( option_set ),
    70     timeout,
    7171    &queue_context
    7272  );
  • cpukit/rtems/src/msgqsend.c

    r7f616dd rf23d470  
    5959    size,
    6060    false,   /* sender does not block */
    61     0,       /* no timeout */
    6261    &queue_context
    6362  );
  • cpukit/rtems/src/msgqurgent.c

    r7f616dd rf23d470  
    5959    size,
    6060    false,   /* sender does not block */
    61     0,       /* no timeout */
    6261    &queue_context
    6362  );
  • cpukit/rtems/src/regiongetsegment.c

    r7f616dd rf23d470  
    8888        STATES_WAITING_FOR_SEGMENT,
    8989        timeout,
     90        WATCHDOG_RELATIVE,
    9091        2
    9192      );
  • cpukit/rtems/src/semobtain.c

    r7f616dd rf23d470  
    7070  wait = !_Options_Is_no_wait( option_set );
    7171
     72  _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
     73
    7274  switch ( the_semaphore->variant ) {
    7375    case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
     
    7678        executing,
    7779        wait,
    78         timeout,
    7980        _CORE_recursive_mutex_Seize_nested,
    8081        &queue_context
     
    8687        executing,
    8788        wait,
    88         timeout,
    8989        _CORE_recursive_mutex_Seize_nested,
    9090        &queue_context
     
    9797        executing,
    9898        wait,
    99         timeout,
    10099        _CORE_recursive_mutex_Seize_nested,
    101100        &queue_context
     
    108107        executing,
    109108        wait,
    110         timeout,
    111109        &queue_context
    112110      );
     
    123121        executing,
    124122        wait,
    125         timeout,
    126123        &queue_context
    127124      );
  • cpukit/score/include/rtems/score/corebarrierimpl.h

    r7f616dd rf23d470  
    8888 *  @param[in,out] executing The currently executing thread.
    8989 *  @param[in] wait is true if the calling thread is willing to wait
    90  *  @param[in] timeout is the number of ticks the calling thread is willing
    91  *         to wait if @a wait is true.
    92  *  @param[in] mp_callout is the routine to invoke if the
    93  *         thread unblocked is remote
    9490 *
    9591 * @return The method status.
     
    9995  Thread_Control       *executing,
    10096  bool                  wait,
    101   Watchdog_Interval     timeout,
    10297  Thread_queue_Context *queue_context
    10398);
  • cpukit/score/include/rtems/score/coremsgimpl.h

    r7f616dd rf23d470  
    195195 *  @param[in] wait indicates whether the calling thread is willing to block
    196196 *         if the message queue is full.
    197  *  @param[in] timeout is the maximum number of clock ticks that the calling
    198  *         thread is willing to block if the message queue is full.
    199197 *  @param[in] queue_context The thread queue context used for
    200198 *    _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
     
    208206  CORE_message_queue_Submit_types   submit_type,
    209207  bool                              wait,
    210   Watchdog_Interval                 timeout,
    211208  Thread_queue_Context             *queue_context
    212209);
     
    231228 *  @param[in] wait indicates whether the calling thread is willing to block
    232229 *         if the message queue is empty.
    233  *  @param[in] timeout is the maximum number of clock ticks that the calling
    234  *         thread is willing to block if the message queue is empty.
    235230 *  @param[in] queue_context The thread queue context used for
    236231 *    _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
     
    252247  size_t                     *size_p,
    253248  bool                        wait,
    254   Watchdog_Interval           timeout,
    255249  Thread_queue_Context       *queue_context
    256250);
     
    282276  size_t                            size,
    283277  bool                              wait,
    284   Watchdog_Interval                 timeout,
    285278  Thread_queue_Context             *queue_context
    286279)
     
    293286    CORE_MESSAGE_QUEUE_SEND_REQUEST,
    294287    wait,
    295     timeout,
    296288    queue_context
    297289  );
     
    303295  size_t                            size,
    304296  bool                              wait,
    305   Watchdog_Interval                 timeout,
    306297  Thread_queue_Context             *queue_context
    307298)
     
    314305    CORE_MESSAGE_QUEUE_URGENT_REQUEST,
    315306    wait,
    316     timeout,
    317307    queue_context
    318308  );
  • cpukit/score/include/rtems/score/coremuteximpl.h

    r7f616dd rf23d470  
    101101  Thread_Control       *owner,
    102102  bool                  wait,
    103   Watchdog_Interval     timeout,
    104103  Thread_queue_Context *queue_context
    105104);
     
    110109  Thread_Control                *executing,
    111110  bool                           wait,
    112   Watchdog_Interval              timeout,
    113111  Thread_queue_Context          *queue_context
    114112);
     
    184182  Thread_Control                *executing,
    185183  bool                           wait,
    186   Watchdog_Interval              timeout,
    187184  Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
    188185  Thread_queue_Context          *queue_context
     
    215212    owner,
    216213    wait,
    217     timeout,
    218214    queue_context
    219215  );
     
    278274  Thread_Control                *executing,
    279275  bool                           wait,
    280   Watchdog_Interval              timeout,
    281276  Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
    282277  Thread_queue_Context          *queue_context
     
    308303    executing,
    309304    wait,
    310     timeout,
    311305    queue_context
    312306  );
     
    435429  Thread_Control                *executing,
    436430  bool                           wait,
    437   Watchdog_Interval              timeout,
    438431  Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
    439432  Thread_queue_Context          *queue_context
     
    477470    executing,
    478471    wait,
    479     timeout,
    480472    queue_context
    481473  );
  • cpukit/score/include/rtems/score/corerwlockimpl.h

    r7f616dd rf23d470  
    9696 *  @param[in] the_rwlock is the RWLock to wait for
    9797 *  @param[in] wait is true if the calling thread is willing to wait
    98  *  @param[in] timeout is the number of ticks the calling thread is willing
    99  *         to wait if @a wait is true.
    10098 */
    10199
     
    104102  Thread_Control       *executing,
    105103  bool                  wait,
    106   Watchdog_Interval     timeout,
    107104  Thread_queue_Context *queue_context
    108105);
     
    115112 *  @param[in] the_rwlock is the RWLock to wait for
    116113 *  @param[in] wait is true if the calling thread is willing to wait
    117  *  @param[in] timeout is the number of ticks the calling thread is willing
    118  *         to wait if @a wait is true.
    119114 */
    120115Status_Control _CORE_RWLock_Seize_for_writing(
     
    122117  Thread_Control       *executing,
    123118  bool                  wait,
    124   Watchdog_Interval     timeout,
    125119  Thread_queue_Context *queue_context
    126120);
  • cpukit/score/include/rtems/score/coresemimpl.h

    r7f616dd rf23d470  
    166166 * @param[in] executing The currently executing thread.
    167167 * @param[in] wait is true if the thread is willing to wait
    168  * @param[in] timeout is the maximum number of ticks to block
    169168 * @param[in] queue_context is a temporary variable used to contain the ISR
    170169 *        disable level cookie
     
    175174  Thread_Control                *executing,
    176175  bool                           wait,
    177   Watchdog_Interval              timeout,
    178176  Thread_queue_Context          *queue_context
    179177)
     
    199197    executing,
    200198    STATES_WAITING_FOR_SEMAPHORE,
    201     timeout,
    202199    queue_context
    203200  );
  • cpukit/score/include/rtems/score/mrspimpl.h

    r7f616dd rf23d470  
    241241  Priority_Control      initial_priority,
    242242  Priority_Control      ceiling_priority,
    243   Watchdog_Interval     timeout,
    244243  Thread_queue_Context *queue_context
    245244)
     
    251250  ISR_lock_Context giant_lock_context;
    252251  ISR_Level level;
     252  Watchdog_Interval timeout = queue_context->timeout;
     253  _Assert( queue_context->timeout_discipline == WATCHDOG_RELATIVE );
    253254
    254255  rival.thread = executing;
     
    318319  Thread_Control       *executing,
    319320  bool                  wait,
    320   Watchdog_Interval     timeout,
    321321  Thread_queue_Context *queue_context
    322322)
     
    358358      initial_priority,
    359359      ceiling_priority,
    360       timeout,
    361360      queue_context
    362361    );
  • cpukit/score/include/rtems/score/threadimpl.h

    r7f616dd rf23d470  
    15121512  _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );
    15131513
    1514   the_thread->Timer.header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
     1514  the_thread->Timer.header = &cpu->Watchdog.Header[PER_CPU_WATCHDOG_RELATIVE];
    15151515  the_thread->Timer.Watchdog.routine = routine;
    15161516  _Watchdog_Per_CPU_insert_relative( &the_thread->Timer.Watchdog, cpu, ticks );
     
    15231523  Per_CPU_Control                *cpu,
    15241524  Watchdog_Service_routine_entry  routine,
    1525   uint64_t                        expire
     1525  uint64_t                        ticks
    15261526)
    15271527{
     
    15301530  _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );
    15311531
    1532   the_thread->Timer.header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ];
     1532  the_thread->Timer.header = &cpu->Watchdog.Header[PER_CPU_WATCHDOG_ABSOLUTE];
    15331533  the_thread->Timer.Watchdog.routine = routine;
    1534   _Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog, cpu, expire );
     1534  _Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog, cpu, ticks );
    15351535
    15361536  _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context );
    15371537}
     1538
     1539
     1540
    15381541
    15391542RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread )
  • cpukit/score/include/rtems/score/threadq.h

    r7f616dd rf23d470  
    2525#include <rtems/score/priority.h>
    2626#include <rtems/score/rbtree.h>
     27#include <rtems/score/watchdog.h>
    2728
    2829#ifdef __cplusplus
     
    7879   */
    7980  uint32_t expected_thread_dispatch_disable_level;
     81
     82  /**
     83   * @brief The clock discipline for the interval timeout.
     84   * Use WATCHDOG_NO_TIMEOUT to block indefinitely.
     85   */
     86  Watchdog_Discipline timeout_discipline;
     87
     88  /**
     89   * @brief Interval to wait.
     90   */
     91  uint64_t timeout;
    8092
    8193  /**
  • cpukit/score/include/rtems/score/threadqimpl.h

    r7f616dd rf23d470  
    8989{
    9090  queue_context->expected_thread_dispatch_disable_level = expected_level;
     91}
     92
     93/**
     94 * @brief Sets an indefinite timeout interval in the thread queue context.
     95 *
     96 * @param queue_context The thread queue context.
     97 * @param timeout The new timeout.
     98 *
     99 * @see _Thread_queue_Enqueue_critical().
     100 */
     101RTEMS_INLINE_ROUTINE void
     102_Thread_queue_Context_set_no_timeout(
     103  Thread_queue_Context *queue_context
     104)
     105{
     106  queue_context->timeout_discipline = WATCHDOG_NO_TIMEOUT;
     107}
     108
     109/**
     110 * @brief Sets a relative timeout in the thread queue context.
     111 *
     112 * @param queue_context The thread queue context.
     113 * @param discipline The clock discipline to use for the timeout.
     114 *
     115 * @see _Thread_queue_Enqueue_critical().
     116 */
     117RTEMS_INLINE_ROUTINE void
     118_Thread_queue_Context_set_relative_timeout(
     119  Thread_queue_Context *queue_context,
     120  Watchdog_Interval     timeout
     121)
     122{
     123  queue_context->timeout_discipline = WATCHDOG_RELATIVE;
     124  queue_context->timeout = timeout;
     125}
     126
     127/**
     128 * @brief Sets an absolute timeout in the thread queue context.
     129 *
     130 * @param queue_context The thread queue context.
     131 * @param discipline The clock discipline to use for the timeout.
     132 *
     133 * @see _Thread_queue_Enqueue_critical().
     134 */
     135RTEMS_INLINE_ROUTINE void
     136_Thread_queue_Context_set_absolute_timeout(
     137  Thread_queue_Context *queue_context,
     138  uint64_t              timeout
     139)
     140{
     141  queue_context->timeout_discipline = WATCHDOG_ABSOLUTE;
     142  queue_context->timeout = timeout;
    91143}
    92144
     
    308360 *
    309361 * This enqueues the thread on the thread queue, blocks the thread, and
    310  * optionally starts the thread timer in case the timeout interval is not
    311  * WATCHDOG_NO_TIMEOUT.
     362 * optionally starts the thread timer in case the timeout discipline is not
     363 * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context.
    312364 *
    313365 * The caller must be the owner of the thread queue lock.  This function will
     
    351403 *       executing,
    352404 *       STATES_WAITING_FOR_MUTEX,
    353  *       WATCHDOG_NO_TIMEOUT,
    354405 *       0,
    355406 *       &queue_context
     
    363414 * @param[in] the_thread The thread to enqueue.
    364415 * @param[in] state The new state of the thread.
    365  * @param[in] timeout Interval to wait.  Use WATCHDOG_NO_TIMEOUT to block
    366  * potentially forever.
    367416 * @param[in] queue_context The thread queue context of the lock acquire.
    368417 */
     
    372421  Thread_Control                *the_thread,
    373422  States_Control                 state,
    374   Watchdog_Interval              timeout,
    375423  Thread_queue_Context          *queue_context
    376424);
     
    386434  States_Control                 state,
    387435  Watchdog_Interval              timeout,
     436  Watchdog_Discipline            discipline,
    388437  uint32_t                       expected_level
    389438)
     
    394443  _Thread_queue_Acquire( the_thread_queue, &queue_context.Lock_context );
    395444  _Thread_queue_Context_set_expected_level( &queue_context, expected_level );
     445  if ( discipline == WATCHDOG_ABSOLUTE ) {
     446    _Thread_queue_Context_set_absolute_timeout( &queue_context, timeout );
     447  } else {
     448    _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
     449  }
    396450  _Thread_queue_Enqueue_critical(
    397451    &the_thread_queue->Queue,
     
    399453    the_thread,
    400454    state,
    401     timeout,
    402455    &queue_context
    403456  );
  • cpukit/score/include/rtems/score/watchdog.h

    r7f616dd rf23d470  
    5454
    5555/**
     56 *  @brief The clock discipline to use for the Watchdog timeout interval.
     57 */
     58typedef enum {
     59
     60  /**
     61   * @brief Indefinite wait.
     62   *
     63   * This is to indicate there is no timeout and not to use a watchdog. It
     64   * must be equal to 0, which is an illegal relative clock interval, so that
     65   * it may be used as a Watchdog_Interval value with WATCHDOG_RELATIVE to
     66   * express an indefinite wait.
     67   */
     68  WATCHDOG_NO_TIMEOUT = 0,
     69
     70  /**
     71   * @brief Relative clock.
     72   *
     73   * The reference time point for the watchdog is current ticks value
     74   * during insert.  Time is measured in clock ticks.
     75   */
     76  WATCHDOG_RELATIVE,
     77
     78  /**
     79   * @brief Absolute clock.
     80   *
     81   * The reference time point for this header is the POSIX Epoch.  Time is
     82   * measured in nanoseconds since POSIX Epoch.
     83   */
     84  WATCHDOG_ABSOLUTE
     85} Watchdog_Discipline;
     86
     87/**
    5688 *  @brief Return type from a Watchdog Service Routine.
    5789 *
     
    6799typedef Watchdog_Service_routine
    68100  ( *Watchdog_Service_routine_entry )( Watchdog_Control * );
    69 
    70 /**
    71  *  @brief The constant for indefinite wait.
    72  *
    73  *  This is the constant for indefinite wait.  It is actually an
    74  *  illegal interval.
    75  */
    76 #define WATCHDOG_NO_TIMEOUT  0
    77101
    78102/**
  • cpukit/score/include/rtems/score/watchdogimpl.h

    r7f616dd rf23d470  
    341341
    342342RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_relative(
    343   Watchdog_Control *the_watchdog,
    344   Per_CPU_Control  *cpu,
    345   uint32_t          ticks
     343  Watchdog_Control    *the_watchdog,
     344  Per_CPU_Control     *cpu,
     345  Watchdog_Interval    ticks
    346346)
    347347{
    348348  ISR_lock_Context lock_context;
     349  Watchdog_Header *header;
    349350  uint64_t expire;
    350351
     
    352353
    353354  _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
    354   expire = cpu->Watchdog.ticks + ticks;
    355   _Watchdog_Insert(
    356     &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    357     the_watchdog,
    358     expire
    359   );
     355
     356  expire = ticks + cpu->Watchdog.ticks;
     357  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
     358
     359  _Watchdog_Insert(header, the_watchdog, expire);
    360360  _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
    361 
    362361  return expire;
    363362}
    364363
    365 RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_insert_absolute(
    366   Watchdog_Control *the_watchdog,
    367   Per_CPU_Control  *cpu,
    368   uint64_t          expire
     364RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_absolute(
     365  Watchdog_Control    *the_watchdog,
     366  Per_CPU_Control     *cpu,
     367  uint64_t             expire
    369368)
    370369{
    371370  ISR_lock_Context lock_context;
     371  Watchdog_Header *header;
    372372
    373373  _Watchdog_Set_CPU( the_watchdog, cpu );
    374374
    375375  _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
    376   _Watchdog_Insert(
    377     &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ],
    378     the_watchdog,
    379     expire
    380   );
     376
     377  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ];
     378
     379  _Watchdog_Insert(header, the_watchdog, expire);
    381380  _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
     381  return expire;
    382382}
    383383
  • cpukit/score/src/apimutexlock.c

    r7f616dd rf23d470  
    3434  _Thread_queue_Context_initialize( &queue_context );
    3535  _ISR_lock_ISR_disable( &queue_context.Lock_context );
    36 
     36  _Thread_queue_Context_set_no_timeout( &queue_context );
    3737  _CORE_recursive_mutex_Seize(
    3838    &the_mutex->Mutex,
    3939    _Thread_Executing,
    4040    true,
    41     WATCHDOG_NO_TIMEOUT,
    4241    _CORE_recursive_mutex_Seize_nested,
    4342    &queue_context
  • cpukit/score/src/condition.c

    r7f616dd rf23d470  
    8383static Per_CPU_Control *_Condition_Do_wait(
    8484  struct _Condition_Control *_condition,
    85   Watchdog_Interval          timeout,
    8685  Thread_queue_Context      *queue_context
    8786)
     
    101100    executing,
    102101    STATES_WAITING_FOR_SYS_LOCK_CONDITION,
    103     timeout,
    104102    queue_context
    105103  );
     
    118116  _Thread_queue_Context_initialize( &queue_context );
    119117  _ISR_lock_ISR_disable( &queue_context.Lock_context );
    120   cpu_self = _Condition_Do_wait( _condition, 0, &queue_context );
     118  _Thread_queue_Context_set_no_timeout( &queue_context );
     119  cpu_self = _Condition_Do_wait(
     120    _condition,
     121    &queue_context
     122  );
    121123
    122124  _Mutex_Release( _mutex );
     
    152154  }
    153155
    154   cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context );
     156  _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
     157  cpu_self = _Condition_Do_wait( _condition, &queue_context );
    155158
    156159  _Mutex_Release( _mutex );
     
    174177  _Thread_queue_Context_initialize( &queue_context );
    175178  _ISR_lock_ISR_disable( &queue_context.Lock_context );
    176   cpu_self = _Condition_Do_wait( _condition, 0, &queue_context );
     179  _Thread_queue_Context_set_no_timeout( &queue_context );
     180  cpu_self = _Condition_Do_wait( _condition, &queue_context );
    177181
    178182  nest_level = _mutex->_nest_level;
     
    212216  }
    213217
    214   cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context );
     218  _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
     219  cpu_self = _Condition_Do_wait( _condition, &queue_context );
    215220
    216221  nest_level = _mutex->_nest_level;
  • cpukit/score/src/corebarrierwait.c

    r7f616dd rf23d470  
    2727  Thread_Control       *executing,
    2828  bool                  wait,
    29   Watchdog_Interval     timeout,
    3029  Thread_queue_Context *queue_context
    3130)
     
    5251      executing,
    5352      STATES_WAITING_FOR_BARRIER,
    54       timeout,
    5553      queue_context
    5654    );
  • cpukit/score/src/coremsgseize.c

    r7f616dd rf23d470  
    3232  size_t                     *size_p,
    3333  bool                        wait,
    34   Watchdog_Interval           timeout,
    3534  Thread_queue_Context       *queue_context
    3635)
     
    121120    executing,
    122121    STATES_WAITING_FOR_MESSAGE,
    123     timeout,
    124122    queue_context
    125123  );
  • cpukit/score/src/coremsgsubmit.c

    r7f616dd rf23d470  
    3434  CORE_message_queue_Submit_types   submit_type,
    3535  bool                              wait,
    36   Watchdog_Interval                 timeout,
    3736  Thread_queue_Context             *queue_context
    3837)
     
    139138      executing,
    140139      STATES_WAITING_FOR_MESSAGE,
    141       timeout,
    142140      queue_context
    143141    );
  • cpukit/score/src/coremutexseize.c

    r7f616dd rf23d470  
    2222#include <rtems/score/statesimpl.h>
    2323#include <rtems/score/thread.h>
     24#include <rtems/score/watchdog.h>
    2425
    2526Status_Control _CORE_mutex_Seize_slow(
     
    2829  Thread_Control       *owner,
    2930  bool                  wait,
    30   Watchdog_Interval     timeout,
    3131  Thread_queue_Context *queue_context
    3232)
     
    7070    executing,
    7171    STATES_WAITING_FOR_MUTEX,
    72     timeout,
    7372    queue_context
    7473  );
     
    8685  Thread_Control                *executing,
    8786  bool                           wait,
    88   Watchdog_Interval              timeout,
    8987  Thread_queue_Context          *queue_context
    9088)
     
    9795      executing,
    9896      STATES_WAITING_FOR_MUTEX,
    99       timeout,
    10097      queue_context
    10198    );
  • cpukit/score/src/corerwlockobtainread.c

    r7f616dd rf23d470  
    2929  Thread_Control       *executing,
    3030  bool                  wait,
    31   Watchdog_Interval     timeout,
    3231  Thread_queue_Context *queue_context
    3332)
     
    8685     executing,
    8786     STATES_WAITING_FOR_RWLOCK,
    88      timeout,
    8987     queue_context
    9088  );
  • cpukit/score/src/corerwlockobtainwrite.c

    r7f616dd rf23d470  
    2929  Thread_Control       *executing,
    3030  bool                  wait,
    31   Watchdog_Interval     timeout,
    3231  Thread_queue_Context *queue_context
    3332)
     
    7473     executing,
    7574     STATES_WAITING_FOR_RWLOCK,
    76      timeout,
    7775     queue_context
    7876  );
  • cpukit/score/src/futex.c

    r7f616dd rf23d470  
    9090  if ( *uaddr == val ) {
    9191    _Thread_queue_Context_set_expected_level( &queue_context, 1 );
     92    _Thread_queue_Context_set_no_timeout( &queue_context );
    9293    _Thread_queue_Enqueue_critical(
    9394      &futex->Queue.Queue,
     
    9596      executing,
    9697      STATES_WAITING_FOR_SYS_LOCK_FUTEX,
    97       WATCHDOG_NO_TIMEOUT,
    9898      &queue_context
    9999    );
  • cpukit/score/src/mpci.c

    r7f616dd rf23d470  
    262262      STATES_WAITING_FOR_RPC_REPLY | extra_state,
    263263      the_packet->timeout,
     264      WATCHDOG_RELATIVE,
    264265      2
    265266    );
     
    329330  executing = _Thread_Get_executing();
    330331  _Thread_queue_Context_initialize( &queue_context );
     332  _Thread_queue_Context_set_no_timeout( &queue_context );
    331333
    332334  for ( ; ; ) {
     
    340342      executing,
    341343      true,
    342       WATCHDOG_NO_TIMEOUT,
    343344      &queue_context
    344345    );
  • cpukit/score/src/mutex.c

    r7f616dd rf23d470  
    105105  Thread_Control       *owner,
    106106  Thread_Control       *executing,
    107   Watchdog_Interval     timeout,
    108107  Thread_queue_Context *queue_context
    109108)
     
    116115    executing,
    117116    STATES_WAITING_FOR_SYS_LOCK_MUTEX,
    118     timeout,
    119117    queue_context
    120118  );
     
    220218    _Mutex_Queue_release( mutex, &queue_context );
    221219  } else {
    222     _Mutex_Acquire_slow( mutex, owner, executing, 0, &queue_context );
     220    _Thread_queue_Context_set_no_timeout( &queue_context );
     221    _Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
    223222  }
    224223}
     
    261260    }
    262261
    263     _Mutex_Acquire_slow( mutex, owner, executing, ticks, &queue_context );
     262    _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
     263    _Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
    264264
    265265    return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
     
    337337    _Mutex_Queue_release( &mutex->Mutex, &queue_context );
    338338  } else {
    339     _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, 0, &queue_context );
     339    _Thread_queue_Context_set_no_timeout( &queue_context );
     340    _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
    340341  }
    341342}
     
    383384    }
    384385
    385     _Mutex_Acquire_slow(
    386       &mutex->Mutex,
    387       owner,
    388       executing,
    389       ticks,
    390       &queue_context
    391     );
     386    _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
     387    _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
    392388
    393389    return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
  • cpukit/score/src/semaphore.c

    r7f616dd rf23d470  
    102102  } else {
    103103    _Thread_queue_Context_set_expected_level( &queue_context, 1 );
     104    _Thread_queue_Context_set_no_timeout( &queue_context );
    104105    _Thread_queue_Enqueue_critical(
    105106      &sem->Queue.Queue,
     
    107108      executing,
    108109      STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE,
    109       WATCHDOG_NO_TIMEOUT,
    110110      &queue_context
    111111    );
  • cpukit/score/src/threadqenqueue.c

    r7f616dd rf23d470  
    4040  Thread_Control                *the_thread,
    4141  States_Control                 state,
    42   Watchdog_Interval              timeout,
    4342  Thread_queue_Context          *queue_context
    4443)
     
    8483   *  If the thread wants to timeout, then schedule its timer.
    8584   */
    86   if ( timeout != WATCHDOG_NO_TIMEOUT ) {
    87     _Thread_Timer_insert_relative(
    88       the_thread,
    89       cpu_self,
    90       _Thread_Timeout,
    91       timeout
    92     );
     85  switch ( queue_context->timeout_discipline ) {
     86    case WATCHDOG_RELATIVE:
     87      /* A relative timeout of 0 is a special case indefinite (no) timeout */
     88      if ( queue_context->timeout != 0 ) {
     89        _Thread_Timer_insert_relative(
     90           the_thread,
     91           cpu_self,
     92           _Thread_Timeout,
     93           (Watchdog_Interval) queue_context->timeout
     94        );
     95      }
     96      break;
     97    case WATCHDOG_ABSOLUTE:
     98      _Thread_Timer_insert_absolute(
     99         the_thread,
     100         cpu_self,
     101         _Thread_Timeout,
     102         queue_context->timeout
     103       );
     104      break;
     105    default:
     106      break;
    93107  }
    94108
  • cpukit/score/src/threadrestart.c

    r7f616dd rf23d470  
    480480    executing,
    481481    waiting_for_join,
    482     WATCHDOG_NO_TIMEOUT,
    483482    queue_context
    484483  );
     
    547546  _Thread_queue_Context_initialize( &queue_context );
    548547  _Thread_queue_Context_set_expected_level( &queue_context, 2 );
     548  _Thread_queue_Context_set_no_timeout( &queue_context );
    549549  _Thread_State_acquire( the_thread, &queue_context.Lock_context );
    550550  _Thread_Join(
Note: See TracChangeset for help on using the changeset viewer.