Changeset 2df7fcf in rtems


Ignore:
Timestamp:
06/14/16 09:45:22 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
4da078a8
Parents:
ce6e9ec2
git-author:
Sebastian Huber <sebastian.huber@…> (06/14/16 09:45:22)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 12:00:27)
Message:

posix: _POSIX_Mutex_Default_attributes

Make _POSIX_Mutex_Default_attributes constant and independent of the
scheduler instance. Use INT_MAX to indicate the default ceiling
priority.

Location:
cpukit/posix
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/Makefile.am

    rce6e9ec2 r2df7fcf  
    2121include_rtems_posix_HEADERS += include/rtems/posix/config.h
    2222include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h
     23include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h
    2324
    2425if HAS_PTHREADS
     
    3839include_rtems_posix_HEADERS += include/rtems/posix/mutex.h
    3940include_rtems_posix_HEADERS += include/rtems/posix/muteximpl.h
    40 include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h
    4141include_rtems_posix_HEADERS += include/rtems/posix/psignal.h
    4242include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h
  • cpukit/posix/include/rtems/posix/muteximpl.h

    rce6e9ec2 r2df7fcf  
    5151 *  The default mutex attributes structure.
    5252 */
    53 extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
     53extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
    5454
    5555RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Acquire_critical(
  • cpukit/posix/include/rtems/posix/priorityimpl.h

    rce6e9ec2 r2df7fcf  
    6161
    6262/**
     63 * @brief Gets the maximum POSIX API priority for this scheduler instance.
     64 *
     65 * Such a priority is valid.  A scheduler instance may support priority values
     66 * that are not representable as an integer.
     67 *
     68 * @return The maximum POSIX API priority for this scheduler instance.
     69 */
     70int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler );
     71
     72/**
    6373 * @brief Check if POSIX priority is valid.
    6474 *
  • cpukit/posix/preinstall.am

    rce6e9ec2 r2df7fcf  
    4444PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/posixapi.h
    4545
     46$(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h: include/rtems/posix/priorityimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
     47        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
     48PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
     49
    4650if HAS_PTHREADS
    4751$(PROJECT_INCLUDE)/aio.h: include/aio.h $(PROJECT_INCLUDE)/$(dirstamp)
     
    8589        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/muteximpl.h
    8690PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/muteximpl.h
    87 
    88 $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h: include/rtems/posix/priorityimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
    89         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
    90 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
    9191
    9292$(PROJECT_INCLUDE)/rtems/posix/psignal.h: include/rtems/posix/psignal.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
  • cpukit/posix/src/mutex.c

    rce6e9ec2 r2df7fcf  
    1919#endif
    2020
    21 #include <errno.h>
    22 #include <pthread.h>
    2321#include <limits.h>
    2422
    25 #include <rtems/system.h>
    2623#include <rtems/config.h>
    2724#include <rtems/sysinit.h>
    28 #include <rtems/score/coremuteximpl.h>
    29 #include <rtems/score/watchdog.h>
    3025#include <rtems/posix/muteximpl.h>
    31 #include <rtems/posix/priorityimpl.h>
     26#include <rtems/score/objectimpl.h>
    3227
    3328Objects_Information _POSIX_Mutex_Information;
    3429
    35 pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
     30const pthread_mutexattr_t _POSIX_Mutex_Default_attributes = {
     31#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
     32  .type           = PTHREAD_MUTEX_DEFAULT,
     33#endif
     34  .is_initialized = true,
     35  .process_shared = PTHREAD_PROCESS_PRIVATE,
     36  .prio_ceiling   = INT_MAX,
     37  .protocol       = PTHREAD_PRIO_NONE,
     38  .recursive      = false
     39};
    3640
    3741/*
     
    4852static void _POSIX_Mutex_Manager_initialization(void)
    4953{
    50   pthread_mutexattr_t *default_attr = &_POSIX_Mutex_Default_attributes;
    51 
    52   /*
    53    * Since the maximum priority is run-time configured, this
    54    * structure cannot be initialized statically.
    55    */
    56   default_attr->is_initialized = true;
    57   default_attr->process_shared = PTHREAD_PROCESS_PRIVATE;
    58   default_attr->prio_ceiling   = POSIX_SCHEDULER_MAXIMUM_PRIORITY;
    59   default_attr->protocol       = PTHREAD_PRIO_NONE;
    60   default_attr->recursive      = false;
    61   #if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
    62     default_attr->type         = PTHREAD_MUTEX_DEFAULT;
    63   #endif
    64 
    6554  /*
    6655   * Initialize the POSIX mutex object class information structure.
  • cpukit/posix/src/mutexinit.c

    rce6e9ec2 r2df7fcf  
    3737  const pthread_mutexattr_t *the_attr;
    3838  POSIX_Mutex_Protocol       protocol;
     39  const Scheduler_Control   *scheduler;
    3940  Priority_Control           priority;
    4041
     
    106107
    107108  if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
    108     if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) ) {
     109    int prio_ceiling;
     110
     111    scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
     112    prio_ceiling = the_attr->prio_ceiling;
     113
     114    if ( prio_ceiling == INT_MAX ) {
     115      prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );
     116    }
     117
     118    if ( !_POSIX_Priority_Is_valid( prio_ceiling ) ) {
    109119      return EINVAL;
    110120    }
    111121
    112     priority = _POSIX_Priority_To_core( the_attr->prio_ceiling );
     122    priority = _POSIX_Priority_To_core( prio_ceiling );
    113123  }
    114124
  • cpukit/posix/src/psxpriorityisvalid.c

    rce6e9ec2 r2df7fcf  
    1919#endif
    2020
    21 #include <rtems/system.h>
    2221#include <rtems/posix/priorityimpl.h>
     22
     23int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler )
     24{
     25  if ( scheduler->maximum_priority < INT_MAX ) {
     26    return (int) scheduler->maximum_priority - 1;
     27  } else {
     28    return INT_MAX;
     29  }
     30}
    2331
    2432bool _POSIX_Priority_Is_valid(
  • cpukit/posix/src/sched_getprioritymax.c

    rce6e9ec2 r2df7fcf  
    2222
    2323#include <sched.h>
    24 #include <errno.h>
    2524
    26 #include <rtems/system.h>
    2725#include <rtems/seterr.h>
     26#include <rtems/posix/priorityimpl.h>
    2827#include <rtems/score/schedulerimpl.h>
    2928
     
    4645
    4746  scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
    48 
    49   if ( scheduler->maximum_priority > INT_MAX ) {
    50     return INT_MAX;
    51   }
    52 
    53   return (int) scheduler->maximum_priority - 1;
     47  return _POSIX_Priority_Get_maximum( scheduler );
    5448}
Note: See TracChangeset for help on using the changeset viewer.