Changeset 127c20e in rtems


Ignore:
Timestamp:
Jun 23, 2016, 8:10:39 PM (3 years ago)
Author:
Gedare Bloom <gedare@…>
Branches:
master
Children:
b5bfaaf9
Parents:
10e4000
git-author:
Gedare Bloom <gedare@…> (06/23/16 20:10:39)
git-committer:
Gedare Bloom <gedare@…> (07/25/16 16:44:47)
Message:

posix: refactor cond wait support to defer abstime conversion

updates #2745

Location:
cpukit/posix
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/condimpl.h

    r10e4000 r127c20e  
    135135  pthread_cond_t            *cond,
    136136  pthread_mutex_t           *mutex,
    137   Watchdog_Interval          timeout,
    138   bool                       already_timedout
     137  const struct timespec     *abstime
    139138);
    140139
  • cpukit/posix/src/condtimedwait.c

    r10e4000 r127c20e  
    3232)
    3333{
    34   Watchdog_Interval                            ticks;
    35   bool                                         already_timedout;
    36   TOD_Absolute_timeout_conversion_results  status;
    37 
    38   /*
    39    *  POSIX requires that blocking calls with timeouts that take
    40    *  an absolute timeout must ignore issues with the absolute
    41    *  time provided if the operation would otherwise succeed.
    42    *  So we check the abstime provided, and hold on to whether it
    43    *  is valid or not.  If it isn't correct and in the future,
    44    *  then we do a polling operation and convert the UNSATISFIED
    45    *  status into the appropriate error.
    46    */
    47   already_timedout = false;
    48   status = _TOD_Absolute_timeout_to_ticks(abstime, &ticks);
    49   if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID )
    50     return EINVAL;
    51 
    52   if ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST ||
    53        status == TOD_ABSOLUTE_TIMEOUT_IS_NOW )
    54     already_timedout = true;
    55 
    5634  return _POSIX_Condition_variables_Wait_support(
    5735    cond,
    5836    mutex,
    59     ticks,
    60     already_timedout
     37    abstime
    6138  );
    6239}
  • cpukit/posix/src/condwait.c

    r10e4000 r127c20e  
    3333    cond,
    3434    mutex,
    35     WATCHDOG_NO_TIMEOUT,
    36     false
     35    NULL
    3736  );
    3837}
  • cpukit/posix/src/condwaitsupp.c

    r10e4000 r127c20e  
    3131  pthread_cond_t            *cond,
    3232  pthread_mutex_t           *mutex,
    33   Watchdog_Interval          timeout,
    34   bool                       already_timedout
     33  const struct timespec     *abstime
    3534)
    3635{
     
    4140  Per_CPU_Control                   *cpu_self;
    4241  Thread_Control                    *executing;
     42  Watchdog_Interval                  timeout;
     43  bool                               already_timedout;
     44  TOD_Absolute_timeout_conversion_results  status;
    4345
    4446  if ( mutex == NULL ) {
     
    5052  if ( the_cond == NULL ) {
    5153    return EINVAL;
     54  }
     55
     56  already_timedout = false;
     57
     58  if ( abstime != NULL ) {
     59    /*
     60     *  POSIX requires that blocking calls with timeouts that take
     61     *  an absolute timeout must ignore issues with the absolute
     62     *  time provided if the operation would otherwise succeed.
     63     *  So we check the abstime provided, and hold on to whether it
     64     *  is valid or not.  If it isn't correct and in the future,
     65     *  then we do a polling operation and convert the UNSATISFIED
     66     *  status into the appropriate error.
     67     */
     68    status = _TOD_Absolute_timeout_to_ticks( abstime, &timeout );
     69    if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID )
     70      return EINVAL;
     71
     72    if ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST ||
     73        status == TOD_ABSOLUTE_TIMEOUT_IS_NOW ) {
     74      already_timedout = true;
     75    } else {
     76      _Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
     77    }
     78  } else {
     79    _Thread_queue_Context_set_no_timeout( &queue_context );
    5280  }
    5381
     
    6997  if ( !already_timedout ) {
    7098    _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 );
    7399    _Thread_queue_Enqueue_critical(
    74100      &the_cond->Wait_queue.Queue,
Note: See TracChangeset for help on using the changeset viewer.