Changeset e67929c in rtems


Ignore:
Timestamp:
Sep 21, 2017, 12:13:16 PM (18 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
89fc9345
Parents:
c090db7
git-author:
Sebastian Huber <sebastian.huber@…> (09/21/17 12:13:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/05/17 12:29:01)
Message:

posix: Implement self-contained POSIX barriers

POSIX barriers are now available in all configurations and no longer
depend on --enable-posix.

Update #2514.
Update #3114.

Files:
2 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libcsupport.h

    rc090db7 re67929c  
    112112
    113113typedef struct {
    114   uint32_t active_barriers;
    115114  uint32_t active_condition_variables;
    116115  uint32_t active_message_queues;
  • cpukit/libcsupport/src/resource_snapshot.c

    rc090db7 re67929c  
    7070  #ifdef RTEMS_POSIX_API
    7171    ,
    72     { OBJECTS_POSIX_API, OBJECTS_POSIX_BARRIERS },
    7372    { OBJECTS_POSIX_API, OBJECTS_POSIX_CONDITION_VARIABLES },
    7473    { OBJECTS_POSIX_API, OBJECTS_POSIX_MESSAGE_QUEUES },
  • cpukit/posix/Makefile.am

    rc090db7 re67929c  
    1717
    1818## Some POSIX threads features are needed all the time
     19include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h
    1920include_rtems_posix_HEADERS += include/rtems/posix/key.h
    2021include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h
     
    5051include_rtems_posix_HEADERS += include/rtems/posix/timer.h
    5152include_rtems_posix_HEADERS += include/rtems/posix/timerimpl.h
    52 include_rtems_posix_HEADERS += include/rtems/posix/barrier.h
    53 include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h
    5453include_rtems_posix_HEADERS += include/rtems/posix/rwlock.h
    5554include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h
     
    6968libposix_a_SOURCES += src/pthreadsetnamenp.c
    7069
     70## BARRIER_C_FILES
     71libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \
     72    src/barrierattrinit.c src/barrierattrsetpshared.c \
     73    src/pbarrierdestroy.c src/pbarrierinit.c \
     74    src/pbarrierwait.c
     75
    7176if HAS_PTHREADS
    7277libposix_a_SOURCES +=  src/pthreadatfork.c
    73 
    74 ## BARRIER_C_FILES
    75 libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \
    76     src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \
    77     src/pbarrierdestroy.c src/pbarrierinit.c \
    78     src/pbarrierwait.c
    7978
    8079## CANCEL_C_FILES
  • cpukit/posix/include/rtems/posix/barrierimpl.h

    rc090db7 re67929c  
    1212 *  On-Line Applications Research Corporation (OAR).
    1313 *
     14 *  Copyright (c) 2017 embedded brains GmbH
     15 *
    1416 *  The license and distribution terms for this file may be
    1517 *  found in the file LICENSE in this distribution or at
     
    2022#define _RTEMS_POSIX_BARRIERIMPL_H
    2123
    22 #include <rtems/posix/barrier.h>
    23 #include <rtems/score/corebarrierimpl.h>
    24 #include <rtems/score/objectimpl.h>
    25 
    2624#include <errno.h>
    2725#include <pthread.h>
     26
     27#include <rtems/score/percpu.h>
     28#include <rtems/score/threadqimpl.h>
    2829
    2930#ifdef __cplusplus
     
    3132#endif
    3233
    33 /**
    34  *  The following defines the information control block used to manage
    35  *  this class of objects.
    36  */
     34#define POSIX_BARRIER_MAGIC 0x1cf03773UL
    3735
    38 extern Objects_Information _POSIX_Barrier_Information;
     36#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    3937
    40 /**
    41  * @brief Allocate a barrier control block.
    42  *
    43  * This function allocates a barrier control block from
    44  * the inactive chain of free barrier control blocks.
    45  */
    46 RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Allocate( void )
     38typedef struct {
     39  unsigned long flags;
     40  Thread_queue_Syslock_queue Queue;
     41  unsigned int count;
     42  unsigned int waiting_threads;
     43} POSIX_Barrier_Control;
     44
     45static inline POSIX_Barrier_Control *_POSIX_Barrier_Get(
     46  pthread_barrier_t *_barrier
     47)
    4748{
    48   return (POSIX_Barrier_Control *)
    49     _Objects_Allocate( &_POSIX_Barrier_Information );
     49  return (POSIX_Barrier_Control *) _barrier;
    5050}
    5151
    52 /**
    53  * @brief Free a barrier control block.
    54  *
    55  * This routine frees a barrier control block to the
    56  * inactive chain of free barrier control blocks.
    57  */
    58 RTEMS_INLINE_ROUTINE void _POSIX_Barrier_Free (
    59   POSIX_Barrier_Control *the_barrier
     52static inline Thread_Control *_POSIX_Barrier_Queue_acquire(
     53  POSIX_Barrier_Control *barrier,
     54  Thread_queue_Context  *queue_context
    6055)
    6156{
    62   _CORE_barrier_Destroy( &the_barrier->Barrier );
    63   _Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object );
     57  ISR_Level       level;
     58  Thread_Control *executing;
     59
     60  _Thread_queue_Context_initialize( queue_context );
     61  _Thread_queue_Context_ISR_disable( queue_context, level );
     62  _Thread_queue_Context_set_ISR_level( queue_context, level );
     63  executing = _Thread_Executing;
     64  _Thread_queue_Queue_acquire_critical(
     65    &barrier->Queue.Queue,
     66    &executing->Potpourri_stats,
     67    &queue_context->Lock_context.Lock_context
     68  );
     69
     70  return executing;
    6471}
    6572
    66 RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get(
    67   const pthread_barrier_t *barrier,
    68   Thread_queue_Context    *queue_context
     73static inline void _POSIX_Barrier_Queue_release(
     74  POSIX_Barrier_Control *barrier,
     75  Thread_queue_Context  *queue_context
    6976)
    7077{
    71   _Thread_queue_Context_initialize( queue_context );
    72   return (POSIX_Barrier_Control *) _Objects_Get(
    73     (Objects_Id) *barrier,
    74     &queue_context->Lock_context.Lock_context,
    75     &_POSIX_Barrier_Information
     78  _Thread_queue_Queue_release(
     79    &barrier->Queue.Queue,
     80    &queue_context->Lock_context.Lock_context
    7681  );
    7782}
     83
     84#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \
     85  do { \
     86    if ( \
     87      ( bar ) == NULL \
     88        || ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \
     89    ) { \
     90      return EINVAL; \
     91    } \
     92  } while ( 0 )
    7893
    7994#ifdef __cplusplus
  • cpukit/posix/include/rtems/posix/config.h

    rc090db7 re67929c  
    101101  /**
    102102   * This field contains the maximum number of POSIX API
    103    * barriers which are configured for this application.
    104    */
    105   uint32_t                            maximum_barriers;
    106 
    107   /**
    108    * This field contains the maximum number of POSIX API
    109103   * read/write locks which are configured for this application.
    110104   */
  • cpukit/posix/preinstall.am

    rc090db7 re67929c  
    2727        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/sigset.h
    2828PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/sigset.h
     29
     30$(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h: include/rtems/posix/barrierimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
     31        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h
     32PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h
    2933
    3034$(PROJECT_INCLUDE)/rtems/posix/key.h: include/rtems/posix/key.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
     
    141145PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h
    142146
    143 $(PROJECT_INCLUDE)/rtems/posix/barrier.h: include/rtems/posix/barrier.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
    144         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.h
    145 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.h
    146 
    147 $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h: include/rtems/posix/barrierimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
    148         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h
    149 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h
    150 
    151147$(PROJECT_INCLUDE)/rtems/posix/rwlock.h: include/rtems/posix/rwlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
    152148        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.h
  • cpukit/posix/src/pbarrierdestroy.c

    rc090db7 re67929c  
    99 *  COPYRIGHT (c) 1989-2007.
    1010 *  On-Line Applications Research Corporation (OAR).
     11 *
     12 *  Copyright (c) 2017 embedded brains GmbH
    1113 *
    1214 *  The license and distribution terms for this file may be
     
    2123#include <rtems/posix/barrierimpl.h>
    2224
    23 /**
    24  *  This directive allows a thread to delete a barrier specified by
    25  *  the barrier id.  The barrier is freed back to the inactive
    26  *  barrier chain.
    27  *
    28  *  @param[in] barrier is the barrier id
    29  *
    30  *  @return This method returns 0 if there was not an
    31  *  error. Otherwise, a status code is returned indicating the
    32  *  source of the error.
    33  */
    34 int pthread_barrier_destroy(
    35   pthread_barrier_t *barrier
    36 )
     25int pthread_barrier_destroy( pthread_barrier_t *_barrier )
    3726{
    38   POSIX_Barrier_Control *the_barrier;
     27  POSIX_Barrier_Control *barrier;
    3928  Thread_queue_Context   queue_context;
    4029
    41   if ( barrier == NULL ) {
    42     return EINVAL;
    43   }
     30  POSIX_BARRIER_VALIDATE_OBJECT( _barrier );
    4431
    45   _Objects_Allocator_lock();
    46   the_barrier = _POSIX_Barrier_Get( barrier, &queue_context );
     32  barrier = _POSIX_Barrier_Get( _barrier );
    4733
    48   if ( the_barrier == NULL ) {
    49     _Objects_Allocator_unlock();
    50     return EINVAL;
    51   }
     34  _POSIX_Barrier_Queue_acquire( barrier, &queue_context );
    5235
    53   _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &queue_context );
    54 
    55   if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
    56     _CORE_barrier_Release( &the_barrier->Barrier, &queue_context );
    57     _Objects_Allocator_unlock();
     36  if ( barrier->waiting_threads != 0 ) {
     37    _POSIX_Barrier_Queue_release( barrier, &queue_context );
    5838    return EBUSY;
    5939  }
    6040
    61   _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
    62   _CORE_barrier_Release( &the_barrier->Barrier, &queue_context );
    63   _POSIX_Barrier_Free( the_barrier );
    64   _Objects_Allocator_unlock();
     41  barrier->flags = 0;
     42  _POSIX_Barrier_Queue_release( barrier, &queue_context );
    6543  return 0;
    6644}
  • cpukit/posix/src/pbarrierinit.c

    rc090db7 re67929c  
    1212 *  On-Line Applications Research Corporation (OAR).
    1313 *
     14 *  Copyright (c) 2017 embedded brains GmbH
     15 *
    1416 *  The license and distribution terms for this file may be
    1517 *  found in the file LICENSE in this distribution or at
     
    2123#endif
    2224
    23 #include <pthread.h>
    24 #include <errno.h>
    25 
    26 #include <rtems/system.h>
    2725#include <rtems/posix/barrierimpl.h>
    2826#include <rtems/posix/posixapi.h>
    2927
    30 /*
    31  *  pthread_barrier_init
    32  *
    33  *  This directive creates a barrier.  A barrier id is returned.
    34  *
    35  *  Input parameters:
    36  *    barrier          - pointer to barrier id
    37  *    attr             - barrier attributes
    38  *    count            - number of threads before automatic release
    39  *
    40  *  Output parameters:
    41  *    barrier     - barrier id
    42  *    0           - if successful
    43  *    error code  - if unsuccessful
    44  */
     28RTEMS_STATIC_ASSERT(
     29  offsetof( POSIX_Barrier_Control, flags )
     30    == offsetof( pthread_barrier_t, _flags ),
     31  POSIX_BARRIER_CONTROL_FLAGS
     32);
     33
     34RTEMS_STATIC_ASSERT(
     35  offsetof( POSIX_Barrier_Control, count )
     36    == offsetof( pthread_barrier_t, _count ),
     37  POSIX_BARRIER_CONTROL_COUNT
     38);
     39
     40RTEMS_STATIC_ASSERT(
     41  offsetof( POSIX_Barrier_Control, waiting_threads )
     42    == offsetof( pthread_barrier_t, _waiting_threads ),
     43  POSIX_BARRIER_CONTROL_WAITING_THREADS
     44);
     45
     46RTEMS_STATIC_ASSERT(
     47  offsetof( POSIX_Barrier_Control, Queue )
     48    == offsetof( pthread_barrier_t, _Queue ),
     49  POSIX_BARRIER_CONTROL_QUEUE
     50);
     51
     52RTEMS_STATIC_ASSERT(
     53  sizeof( POSIX_Barrier_Control ) == sizeof( pthread_barrier_t ),
     54  POSIX_BARRIER_CONTROL_SIZE
     55);
    4556
    4657int pthread_barrier_init(
    47   pthread_barrier_t           *barrier,
     58  pthread_barrier_t           *_barrier,
    4859  const pthread_barrierattr_t *attr,
    4960  unsigned int                 count
    5061)
    5162{
    52   POSIX_Barrier_Control         *the_barrier;
    53   CORE_barrier_Attributes        the_attributes;
    54   pthread_barrierattr_t          my_attr;
    55   const pthread_barrierattr_t   *the_attr;
     63  POSIX_Barrier_Control *barrier;
     64
     65  barrier = _POSIX_Barrier_Get( _barrier );
    5666
    5767  /*
    5868   *  Error check parameters
    5969   */
    60   if ( !barrier )
    61     return EINVAL;
    62 
    63   if ( count == 0 )
    64     return EINVAL;
    65 
    66   /*
    67    * If the user passed in NULL, use the default attributes
    68    */
    69   if ( attr ) {
    70     the_attr = attr;
    71   } else {
    72     (void) pthread_barrierattr_init( &my_attr );
    73     the_attr = &my_attr;
    74   }
    75 
    76   /*
    77    * Now start error checking the attributes that we are going to use
    78    */
    79   if ( !the_attr->is_initialized )
    80     return EINVAL;
    81 
    82   if ( !_POSIX_Is_valid_pshared( the_attr->process_shared ) ) {
     70  if ( barrier == NULL ) {
    8371    return EINVAL;
    8472  }
    8573
    86   /*
    87    * Convert from POSIX attributes to Core Barrier attributes
    88    */
    89   the_attributes.discipline    = CORE_BARRIER_AUTOMATIC_RELEASE;
    90   the_attributes.maximum_count = count;
    91 
    92   the_barrier = _POSIX_Barrier_Allocate();
    93 
    94   if ( !the_barrier ) {
    95     _Objects_Allocator_unlock();
    96     return EAGAIN;
     74  if ( count == 0 ) {
     75    return EINVAL;
    9776  }
    9877
    99   _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
     78  if ( attr != NULL ) {
     79    /*
     80     * Now start error checking the attributes that we are going to use
     81     */
     82    if ( !attr->is_initialized )
     83      return EINVAL;
    10084
    101   _Objects_Open_u32(
    102     &_POSIX_Barrier_Information,
    103     &the_barrier->Object,
    104     0
    105   );
     85    if ( !_POSIX_Is_valid_pshared( attr->process_shared ) ) {
     86      return EINVAL;
     87    }
     88  }
    10689
    107   *barrier = the_barrier->Object.id;
    108   _Objects_Allocator_unlock();
     90  barrier->flags = (uintptr_t) barrier ^ POSIX_BARRIER_MAGIC;
     91  barrier->count = count;
     92  barrier->waiting_threads = 0;
     93  _Thread_queue_Queue_initialize( &barrier->Queue.Queue, NULL );
    10994  return 0;
    11095}
  • cpukit/posix/src/pbarrierwait.c

    rc090db7 re67929c  
    99 *  COPYRIGHT (c) 1989-2007.
    1010 *  On-Line Applications Research Corporation (OAR).
     11 *
     12 *  Copyright (c) 2017 embedded brains GmbH
    1113 *
    1214 *  The license and distribution terms for this file may be
     
    2224#include <rtems/posix/posixapi.h>
    2325
    24 THREAD_QUEUE_OBJECT_ASSERT( POSIX_Barrier_Control, Barrier.Wait_queue );
     26int pthread_barrier_wait( pthread_barrier_t *_barrier )
     27{
     28  POSIX_Barrier_Control *barrier;
     29  Thread_queue_Context   queue_context;
     30  Thread_Control        *executing;
     31  unsigned int           waiting_threads;
    2532
    26 int pthread_barrier_wait(
    27   pthread_barrier_t *barrier
    28 )
    29 {
    30   POSIX_Barrier_Control *the_barrier;
    31   Thread_queue_Context   queue_context;
    32   Status_Control         status;
     33  POSIX_BARRIER_VALIDATE_OBJECT( _barrier );
    3334
    34   if ( barrier == NULL ) {
    35     return EINVAL;
     35  barrier = _POSIX_Barrier_Get( _barrier );
     36
     37  executing = _POSIX_Barrier_Queue_acquire( barrier, &queue_context );
     38  waiting_threads = barrier->waiting_threads;
     39  ++waiting_threads;
     40
     41  if ( waiting_threads == barrier->count ) {
     42    barrier->waiting_threads = 0;
     43    _Thread_queue_Flush_critical(
     44      &barrier->Queue.Queue,
     45      POSIX_BARRIER_TQ_OPERATIONS,
     46      _Thread_queue_Flush_default_filter,
     47      &queue_context
     48    );
     49    return PTHREAD_BARRIER_SERIAL_THREAD;
     50  } else {
     51    barrier->waiting_threads = waiting_threads;
     52    _Thread_queue_Context_set_thread_state(
     53      &queue_context,
     54      STATES_WAITING_FOR_BARRIER
     55    );
     56    _Thread_queue_Context_set_do_nothing_enqueue_callout( &queue_context );
     57    _Thread_queue_Context_set_no_timeout( &queue_context );
     58    _Thread_queue_Enqueue(
     59      &barrier->Queue.Queue,
     60      POSIX_BARRIER_TQ_OPERATIONS,
     61      executing,
     62      &queue_context
     63    );
     64    return 0;
    3665  }
    37 
    38   the_barrier = _POSIX_Barrier_Get( barrier, &queue_context );
    39 
    40   if ( the_barrier == NULL ) {
    41     return EINVAL;
    42   }
    43 
    44   _Thread_queue_Context_set_no_timeout( &queue_context );
    45   status = _CORE_barrier_Seize(
    46     &the_barrier->Barrier,
    47     _Thread_Executing,
    48     true,
    49     &queue_context
    50   );
    51   return _POSIX_Get_error( status );
    5266}
  • cpukit/rtems/src/rtemsobjectgetapiclassname.c

    rc090db7 re67929c  
    5454  { "Condition Variable",      OBJECTS_POSIX_CONDITION_VARIABLES, 0},
    5555  { "Timer",                   OBJECTS_POSIX_TIMERS, 0},
    56   { "Barrier",                 OBJECTS_POSIX_BARRIERS, 0},
    5756  { "RWLock",                  OBJECTS_POSIX_RWLOCKS, 0},
    5857  { "Shared Memory",           OBJECTS_POSIX_SHMS, 0},
  • cpukit/sapi/include/confdefs.h

    rc090db7 re67929c  
    20822082        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
    20832083    #endif
    2084     #if !defined(CONFIGURE_MAXIMUM_POSIX_BARRIERS)
    2085       #define CONFIGURE_MAXIMUM_POSIX_BARRIERS \
    2086         rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
    2087     #endif
    20882084    #if !defined(CONFIGURE_MAXIMUM_POSIX_RWLOCKS)
    20892085      #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS \
     
    24492445  #include <limits.h>
    24502446  #include <mqueue.h>
    2451   #include <rtems/posix/barrier.h>
    24522447  #include <rtems/posix/cond.h>
    24532448  #include <rtems/posix/mqueue.h>
     
    25712566    _Configure_POSIX_Named_Object_RAM( \
    25722567       _semaphores, sizeof(POSIX_Semaphore_Control) )
    2573 
    2574   /**
    2575    * This configuration parameter specifies the maximum number of
    2576    * POSIX API barriers.
    2577    */
    2578   #ifndef CONFIGURE_MAXIMUM_POSIX_BARRIERS
    2579     #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 0
    2580   #endif
    2581 
    2582   /*
    2583    * This macro is calculated to specify the memory required for
    2584    * POSIX API barriers.
    2585    */
    2586   #define _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(_barriers) \
    2587     _Configure_Object_RAM(_barriers, sizeof(POSIX_Barrier_Control) )
    25882568
    25892569  /**
     
    28432823      _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
    28442824        CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \
    2845       _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(CONFIGURE_MAXIMUM_POSIX_BARRIERS) + \
    28462825      _CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \
    28472826        CONFIGURE_MAXIMUM_POSIX_RWLOCKS) + \
     
    32973276      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES,
    32983277      CONFIGURE_MAXIMUM_POSIX_SEMAPHORES,
    3299       CONFIGURE_MAXIMUM_POSIX_BARRIERS,
    33003278      CONFIGURE_MAXIMUM_POSIX_RWLOCKS,
    33013279      CONFIGURE_MAXIMUM_POSIX_SHMS,
     
    35133491    uint32_t POSIX_MESSAGE_QUEUES;
    35143492    uint32_t POSIX_SEMAPHORES;
    3515     uint32_t POSIX_BARRIERS;
    35163493    uint32_t POSIX_RWLOCKS;
    35173494    uint32_t POSIX_SHMS;
     
    35673544      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ),
    35683545    _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ),
    3569     _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS( CONFIGURE_MAXIMUM_POSIX_BARRIERS ),
    35703546    _CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( CONFIGURE_MAXIMUM_POSIX_RWLOCKS ),
    35713547    _CONFIGURE_MEMORY_FOR_POSIX_SHMS( CONFIGURE_MAXIMUM_POSIX_SHMS ),
     
    36393615       (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \
    36403616       (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \
    3641        (CONFIGURE_MAXIMUM_POSIX_BARRIERS != 0) || \
    36423617       (CONFIGURE_MAXIMUM_POSIX_RWLOCKS != 0) || \
    36433618       (CONFIGURE_MAXIMUM_POSIX_SHMS != 0) || \
  • cpukit/sapi/src/posixapi.c

    rc090db7 re67929c  
    2121
    2222#include <rtems/posix/posixapi.h>
     23#include <rtems/posix/barrierimpl.h>
    2324#include <rtems/posix/semaphoreimpl.h>
    2425#include <rtems/score/heap.h>
     
    4546  POSIX_SEMAPHORE_MAGIC_4
    4647);
     48RTEMS_STATIC_ASSERT(
     49  POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_0,
     50  POSIX_BARRIER_MAGIC_0
     51);
     52RTEMS_STATIC_ASSERT(
     53  POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_1,
     54  POSIX_BARRIER_MAGIC_1
     55);
     56RTEMS_STATIC_ASSERT(
     57  POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_0,
     58  POSIX_BARRIER_MAGIC_2
     59);
     60RTEMS_STATIC_ASSERT(
     61  POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_1,
     62  POSIX_BARRIER_MAGIC_3
     63);
     64RTEMS_STATIC_ASSERT(
     65  POSIX_BARRIER_MAGIC != HEAP_FREE_PATTERN,
     66  POSIX_BARRIER_MAGIC_4
     67);
    4768#endif
     69
     70RTEMS_STATIC_ASSERT(
     71  POSIX_SEMAPHORE_MAGIC != POSIX_BARRIER_MAGIC,
     72  POSIX_SEMAPHORE_MAGIC_5
     73);
    4874
    4975void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno )
  • cpukit/score/include/rtems/score/objectimpl.h

    rc090db7 re67929c  
    9292  OBJECTS_POSIX_CONDITION_VARIABLES = 8,
    9393  OBJECTS_POSIX_TIMERS              = 9,
    94   OBJECTS_POSIX_BARRIERS            = 10,
    9594  OBJECTS_POSIX_RWLOCKS             = 11,
    9695  OBJECTS_POSIX_SHMS                = 12
  • cpukit/score/include/rtems/sysinit.h

    rc090db7 re67929c  
    5353#define RTEMS_SYSINIT_POSIX_SEMAPHORE            000365
    5454#define RTEMS_SYSINIT_POSIX_TIMER                000366
    55 #define RTEMS_SYSINIT_POSIX_BARRIER              000367
    5655#define RTEMS_SYSINIT_POSIX_RWLOCK               000368
    5756#define RTEMS_SYSINIT_POSIX_SHM                  000369
  • testsuites/psxtests/psxbarrier01/main.c

    rc090db7 re67929c  
    4141#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
    4242
    43 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 1
    44 
    4543#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    4644
  • testsuites/psxtests/psxbarrier01/psxbarrier01.scn

    rc090db7 re67929c  
    2424pthread_barrier_init( &barrier, &attr, 1 ) -- OK
    2525pthread_barrier_destroy( &barrier ) -- OK
    26 pthread_barrier_init( &barrier, NULL, 1 ) -- OK
    27 pthread_barrier_init( &barrier, NULL, 1 ) -- EAGAIN
    28 pthread_barrier_destroy( &barrier ) -- OK
    2926pthread_barrierattr_destroy( &attr ) -- OK
    3027pthread_barrier_destroy( NULL ) -- EINVAL
    31 pthread_barrier_destroy( &bad_barrier ) -- EINVAL
     28pthread_barrier_destroy( bad_barrier ) -- EINVAL
    3229pthread_barrier_wait( NULL ) -- EINVAL
    33 pthread_barrier_wait( &bad_barrier ) -- EINVAL
     30pthread_barrier_wait( bad_barrier ) -- EINVAL
    3431pthread_barrierattr_init( &attr ) -- OK
    3532pthread_barrier_init( &barrier, &attr, 2 ) -- OK
  • testsuites/psxtests/psxbarrier01/test.c

    rc090db7 re67929c  
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     7 *  Copyright (c) 2017 embedded brains GmbH
     8 *
    79 *  The license and distribution terms for this file may be
    810 *  found in the file LICENSE in this distribution or at
     
    1719#include <errno.h>
    1820#include <stdlib.h>
     21#include <string.h>
    1922
    2023/* #define __USE_XOPEN2K XXX already defined on GNU/Linux */
     
    2427
    2528const char rtems_test_name[] = "PSXBARRIER 1";
     29
     30static void test_barrier_null( void )
     31{
     32  int eno;
     33
     34  eno = pthread_barrier_init( NULL, NULL, 1 );
     35  rtems_test_assert( eno == EINVAL );
     36
     37  eno = pthread_barrier_wait( NULL );
     38  rtems_test_assert( eno == EINVAL );
     39
     40  eno = pthread_barrier_destroy( NULL );
     41  rtems_test_assert( eno == EINVAL );
     42}
     43
     44static void test_barrier_not_initialized( void )
     45{
     46  pthread_barrier_t bar;
     47  int eno;
     48
     49  memset( &bar, 0xff, sizeof( bar ) );
     50
     51  eno = pthread_barrier_wait(& bar) ;
     52  rtems_test_assert( eno == EINVAL );
     53
     54  eno = pthread_barrier_destroy( &bar );
     55  rtems_test_assert( eno == EINVAL );
     56}
     57
     58static void test_barrier_invalid_copy( void )
     59{
     60  pthread_barrier_t bar;
     61  pthread_barrier_t bar2;
     62  int eno;
     63
     64  eno = pthread_barrier_init( &bar, NULL, 1 );
     65  rtems_test_assert( eno == 0 );
     66
     67  memcpy( &bar2, &bar, sizeof( bar2 ) );
     68
     69  eno = pthread_barrier_wait( &bar2 );
     70  rtems_test_assert( eno == EINVAL );
     71
     72  eno = pthread_barrier_destroy( &bar2 );
     73  rtems_test_assert( eno == EINVAL );
     74
     75  eno = pthread_barrier_destroy( &bar );
     76  rtems_test_assert( eno == 0 );
     77}
    2678
    2779#define NUMBER_THREADS 2
     
    58110#endif
    59111{
    60   pthread_barrier_t     bad_barrier = 100;
     112  pthread_barrier_t    *bad_barrier = NULL;
    61113  pthread_barrier_t     barrier;
    62114  pthread_barrierattr_t attr;
     
    179231  rtems_test_assert( status == 0 );
    180232
    181   /* allocating too many */
    182   puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- OK" );
    183   status = pthread_barrier_init( &barrier, NULL, 1 );
    184   rtems_test_assert( status == 0 );
    185 
    186   puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- EAGAIN" );
    187   status = pthread_barrier_init( &barrier, NULL, 1 );
    188   rtems_test_assert( status == EAGAIN );
    189 
    190   /* clean up */
    191   puts( "pthread_barrier_destroy( &barrier ) -- OK" );
    192   status = pthread_barrier_destroy( &barrier );
    193   rtems_test_assert( status == 0 );
    194 
    195233  puts( "pthread_barrierattr_destroy( &attr ) -- OK" );
    196234  status = pthread_barrierattr_destroy( &attr );
     
    203241  rtems_test_assert( status == EINVAL );
    204242
    205   puts( "pthread_barrier_destroy( &bad_barrier ) -- EINVAL" );
    206   status = pthread_barrier_destroy( &bad_barrier );
     243  puts( "pthread_barrier_destroy( bad_barrier ) -- EINVAL" );
     244  status = pthread_barrier_destroy( bad_barrier );
    207245  rtems_test_assert( status == EINVAL );
    208246
     
    213251  rtems_test_assert( status == EINVAL );
    214252
    215   puts( "pthread_barrier_wait( &bad_barrier ) -- EINVAL" );
    216   status = pthread_barrier_wait( &bad_barrier );
     253  puts( "pthread_barrier_wait( bad_barrier ) -- EINVAL" );
     254  status = pthread_barrier_wait( bad_barrier );
    217255  rtems_test_assert( status == EINVAL );
    218256
     
    225263  status = pthread_barrier_init( &barrier, &attr, 2 );
    226264  rtems_test_assert( status == 0 );
    227   rtems_test_assert( barrier != 0 );
    228265
    229266  puts( "pthread_barrier_destroy( &barrier ) -- OK" );
     
    235272  status = pthread_barrier_init( &Barrier, &attr, NUMBER_THREADS );
    236273  rtems_test_assert( status == 0 );
    237   rtems_test_assert( barrier != 0 );
    238274
    239275  for (i=0 ; i<NUMBER_THREADS ; i++ ) {
     
    254290  }
    255291
     292  test_barrier_null();
     293  test_barrier_not_initialized();
     294  test_barrier_invalid_copy();
     295
    256296  /*************** END OF TEST *****************/
    257297  TEST_END();
  • testsuites/psxtests/psxconfig01/init.c

    rc090db7 re67929c  
    6161#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17
    6262
    63 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 31
    6463#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29
    6564#define POSIX_MQ_COUNT 5
     
    432431#endif
    433432
    434 #ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS
    435   for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_BARRIERS; ++i) {
    436     pthread_barrier_t barrier;
    437     eno = pthread_barrier_init(&barrier, NULL, 1);
    438     rtems_test_assert(eno == 0);
    439   }
    440   rtems_resource_snapshot_take(&snapshot);
    441   rtems_test_assert(
    442     snapshot.posix_api.active_barriers == CONFIGURE_MAXIMUM_POSIX_BARRIERS
    443   );
    444 #endif
    445 
    446433#ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
    447434  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES; ++i) {
  • testsuites/psxtmtests/psxtmbarrier01/init.c

    rc090db7 re67929c  
    9292
    9393#define CONFIGURE_MAXIMUM_POSIX_THREADS     1
    94 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
    9594#define CONFIGURE_POSIX_INIT_THREAD_TABLE
    9695
  • testsuites/psxtmtests/psxtmbarrier02/init.c

    rc090db7 re67929c  
    134134
    135135#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
    136 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
    137136#define CONFIGURE_POSIX_INIT_THREAD_TABLE
    138137
  • testsuites/psxtmtests/psxtmbarrier03/init.c

    rc090db7 re67929c  
    9999
    100100#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
    101 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
    102101#define CONFIGURE_POSIX_INIT_THREAD_TABLE
    103102
  • testsuites/psxtmtests/psxtmbarrier04/init.c

    rc090db7 re67929c  
    9191
    9292#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
    93 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
    9493#define CONFIGURE_POSIX_INIT_THREAD_TABLE
    9594
  • testsuites/sptests/spsysinit01/init.c

    rc090db7 re67929c  
    115115  POSIX_TIMER_PRE,
    116116  POSIX_TIMER_POST,
    117   POSIX_BARRIER_PRE,
    118   POSIX_BARRIER_POST,
    119117  POSIX_RWLOCK_PRE,
    120118  POSIX_RWLOCK_POST,
     
    506504}
    507505
    508 FIRST(RTEMS_SYSINIT_POSIX_BARRIER)
    509 {
    510   assert(_POSIX_Barrier_Information.maximum == 0);
    511   next_step(POSIX_BARRIER_PRE);
    512 }
    513 
    514 LAST(RTEMS_SYSINIT_POSIX_BARRIER)
    515 {
    516   assert(_POSIX_Barrier_Information.maximum != 0);
    517   next_step(POSIX_BARRIER_POST);
    518 }
    519 
    520506FIRST(RTEMS_SYSINIT_POSIX_RWLOCK)
    521507{
     
    758744#ifdef RTEMS_POSIX_API
    759745
    760 #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 1
    761 
    762746#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1
    763747
Note: See TracChangeset for help on using the changeset viewer.