Changeset 1a4eac5 in rtems


Ignore:
Timestamp:
Jun 15, 2016, 2:31:33 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
c82835a
Parents:
5a32c48
git-author:
Sebastian Huber <sebastian.huber@…> (06/15/16 14:31:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 12:00:28)
Message:

posix: Generalize _POSIX_Priority_To_core()

Move POSIX API priority validation into _POSIX_Priority_To_core().

Location:
cpukit/posix
Files:
7 edited

Legend:

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

    r5a32c48 r1a4eac5  
    5252
    5353/**
    54  * @brief Check if POSIX priority is valid.
     54 * @brief Converts the POSIX API priority to the corresponding SuperCore
     55 * priority and validates it.
    5556 *
    5657 * According to POSIX, numerically higher values represent higher priorities.
     
    6667 *
    6768 * @param[in] scheduler The scheduler instance.
    68  * @param[in] priority The POSIX API priority to test.
     69 * @param[in] priority The POSIX API priority to convert and validate.
     70 * @param[out] valid Indicates if the POSIX API priority is valid and a
     71 *   corresponding SuperCore priority in the specified scheduler instance
     72 *   exists.
    6973 *
    70  * @retval true The priority is valid.
    71  * @retval false Otherwise.
     74 * @return The corresponding SuperCore priority.
    7275 */
    73 bool _POSIX_Priority_Is_valid(
     76Priority_Control _POSIX_Priority_To_core(
    7477  const Scheduler_Control *scheduler,
    75   int                      priority
     78  int                      priority,
     79  bool                    *valid
    7680);
    7781
  • cpukit/posix/src/mutexinit.c

    r5a32c48 r1a4eac5  
    108108
    109109  if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
    110     int prio_ceiling;
     110    int  prio_ceiling;
     111    bool valid;
    111112
    112113    scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
     
    117118    }
    118119
    119     if ( !_POSIX_Priority_Is_valid( scheduler, prio_ceiling ) ) {
     120    priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );
     121    if ( !valid ) {
    120122      return EINVAL;
    121123    }
    122 
    123     priority = _POSIX_Priority_To_core( scheduler, prio_ceiling );
    124124  }
    125125
  • cpukit/posix/src/mutexsetprioceiling.c

    r5a32c48 r1a4eac5  
    3434  POSIX_Mutex_Control     *the_mutex;
    3535  const Scheduler_Control *scheduler;
     36  bool                     valid;
     37  Priority_Control         priority;
    3638  int                      error;
    3739  int                      unlock_error;
     
    6062  );
    6163
    62   if ( _POSIX_Priority_Is_valid( scheduler, prioceiling ) ) {
    63     Priority_Control priority;
    64 
    65     priority = _POSIX_Priority_To_core( scheduler, prioceiling );
     64  priority = _POSIX_Priority_To_core( scheduler, prioceiling, &valid );
     65  if ( valid ) {
    6666    the_mutex->Mutex.priority_ceiling = priority;
    67 
    6867    error = 0;
    6968  } else {
  • cpukit/posix/src/psxpriorityisvalid.c

    r5a32c48 r1a4eac5  
    3030}
    3131
    32 bool _POSIX_Priority_Is_valid(
     32Priority_Control _POSIX_Priority_To_core(
    3333  const Scheduler_Control *scheduler,
    34   int                      priority
     34  int                      posix_priority,
     35  bool                    *valid
    3536)
    3637{
    37   return priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY
    38     && (Priority_Control) priority < scheduler->maximum_priority;
     38  Priority_Control core_posix_priority;
     39  Priority_Control core_priority;
     40
     41  core_posix_priority = (Priority_Control) posix_priority;
     42  core_priority = scheduler->maximum_priority - core_posix_priority;
     43
     44  *valid = ( posix_priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY
     45    && core_posix_priority < scheduler->maximum_priority );
     46
     47  return core_priority;
    3948}
    40 
  • cpukit/posix/src/pthreadcreate.c

    r5a32c48 r1a4eac5  
    6363  int                                 low_prio;
    6464  int                                 high_prio;
     65  bool                                valid;
    6566  Priority_Control                    core_low_prio;
    6667  Priority_Control                    core_high_prio;
     
    155156  scheduler = _Scheduler_Get_own( executing );
    156157
    157   if ( !_POSIX_Priority_Is_valid( scheduler, low_prio ) ) {
    158     return EINVAL;
    159   }
    160 
    161   if ( !_POSIX_Priority_Is_valid( scheduler, high_prio ) ) {
    162     return EINVAL;
    163   }
    164 
    165   core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio );
    166   core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio );
     158  core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
     159  if ( !valid ) {
     160    return EINVAL;
     161  }
     162
     163  core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio, &valid );
     164  if ( !valid ) {
     165    return EINVAL;
     166  }
    167167
    168168#if defined(RTEMS_SMP)
  • cpukit/posix/src/pthreadsetschedparam.c

    r5a32c48 r1a4eac5  
    5151  int                            low_prio;
    5252  int                            high_prio;
     53  bool                           valid;
    5354  Priority_Control               core_low_prio;
    5455  Priority_Control               core_high_prio;
     
    6768  }
    6869
    69   if ( !_POSIX_Priority_Is_valid( scheduler, low_prio ) ) {
     70  core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
     71  if ( !valid ) {
    7072    context->error = EINVAL;
    7173    return false;
    7274  }
    7375
    74   if ( !_POSIX_Priority_Is_valid( scheduler, high_prio ) ) {
     76  core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio, &valid );
     77  if ( !valid ) {
    7578    context->error = EINVAL;
    7679    return false;
    7780  }
    78 
    79   core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio );
    80   core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio );
    8181
    8282  *new_priority_p = core_high_prio;
  • cpukit/posix/src/pthreadsetschedprio.c

    r5a32c48 r1a4eac5  
    3434  const Scheduler_Control      *scheduler;
    3535  POSIX_API_Control            *api;
     36  bool                          valid;
    3637  Priority_Control              current_priority;
    3738  Priority_Control              new_priority;
     
    4142  scheduler = _Scheduler_Get_own( the_thread );
    4243
    43   if ( !_POSIX_Priority_Is_valid( scheduler, prio ) ) {
     44  new_priority = _POSIX_Priority_To_core( scheduler, prio, &valid );
     45  if ( !valid ) {
    4446    context->error = EINVAL;
    4547    return false;
    4648  }
    4749
    48   new_priority = _POSIX_Priority_To_core( scheduler, prio );
    4950  *new_priority_p = new_priority;
    5051
Note: See TracChangeset for help on using the changeset viewer.