From e67929c4c0025ef46053523be4c8736dd178cbec Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 21 Sep 2017 14:13:16 +0200 Subject: 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. --- cpukit/libcsupport/include/rtems/libcsupport.h | 1 - cpukit/libcsupport/src/resource_snapshot.c | 1 - cpukit/posix/Makefile.am | 11 ++- cpukit/posix/include/rtems/posix/barrier.h | 64 -------------- cpukit/posix/include/rtems/posix/barrierimpl.h | 87 +++++++++++-------- cpukit/posix/include/rtems/posix/config.h | 6 -- cpukit/posix/preinstall.am | 12 +-- cpukit/posix/src/pbarrier.c | 51 ----------- cpukit/posix/src/pbarrierdestroy.c | 44 +++------- cpukit/posix/src/pbarrierinit.c | 113 +++++++++++-------------- cpukit/posix/src/pbarrierwait.c | 58 ++++++++----- cpukit/rtems/src/rtemsobjectgetapiclassname.c | 1 - cpukit/sapi/include/confdefs.h | 25 ------ cpukit/sapi/src/posixapi.c | 26 ++++++ cpukit/score/include/rtems/score/objectimpl.h | 1 - cpukit/score/include/rtems/sysinit.h | 1 - 16 files changed, 182 insertions(+), 320 deletions(-) delete mode 100644 cpukit/posix/include/rtems/posix/barrier.h delete mode 100644 cpukit/posix/src/pbarrier.c (limited to 'cpukit') diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h index e51b250f13..ace61c5c0d 100644 --- a/cpukit/libcsupport/include/rtems/libcsupport.h +++ b/cpukit/libcsupport/include/rtems/libcsupport.h @@ -111,7 +111,6 @@ typedef struct { } rtems_resource_rtems_api; typedef struct { - uint32_t active_barriers; uint32_t active_condition_variables; uint32_t active_message_queues; uint32_t active_mutexes; diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index 9e026ff222..87d4a0108a 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -69,7 +69,6 @@ static const struct { { OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS } #ifdef RTEMS_POSIX_API , - { OBJECTS_POSIX_API, OBJECTS_POSIX_BARRIERS }, { OBJECTS_POSIX_API, OBJECTS_POSIX_CONDITION_VARIABLES }, { OBJECTS_POSIX_API, OBJECTS_POSIX_MESSAGE_QUEUES }, { OBJECTS_POSIX_API, OBJECTS_POSIX_MUTEXES }, diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index 1d9e209101..7980ca3cc5 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -16,6 +16,7 @@ include_rtems_posixdir = $(includedir)/rtems/posix include_rtems_posix_HEADERS = include/rtems/posix/sigset.h ## Some POSIX threads features are needed all the time +include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h include_rtems_posix_HEADERS += include/rtems/posix/key.h include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h include_rtems_posix_HEADERS += include/rtems/posix/config.h @@ -49,8 +50,6 @@ include_rtems_posix_HEADERS += include/rtems/posix/shmimpl.h include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h include_rtems_posix_HEADERS += include/rtems/posix/timer.h include_rtems_posix_HEADERS += include/rtems/posix/timerimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/barrier.h -include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h include_rtems_posix_HEADERS += include/rtems/posix/rwlock.h include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h @@ -68,15 +67,15 @@ libposix_a_SOURCES += src/wait.c src/waitpid.c libposix_a_SOURCES += src/pthreadgetnamenp.c libposix_a_SOURCES += src/pthreadsetnamenp.c -if HAS_PTHREADS -libposix_a_SOURCES += src/pthreadatfork.c - ## BARRIER_C_FILES libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \ - src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \ + src/barrierattrinit.c src/barrierattrsetpshared.c \ src/pbarrierdestroy.c src/pbarrierinit.c \ src/pbarrierwait.c +if HAS_PTHREADS +libposix_a_SOURCES += src/pthreadatfork.c + ## CANCEL_C_FILES libposix_a_SOURCES += src/cancel.c \ src/cleanuppush.c src/setcancelstate.c \ diff --git a/cpukit/posix/include/rtems/posix/barrier.h b/cpukit/posix/include/rtems/posix/barrier.h deleted file mode 100644 index e445586511..0000000000 --- a/cpukit/posix/include/rtems/posix/barrier.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Associated with the POSIX Barrier Manager - * - * This include file contains all the constants and structures associated - * with the POSIX Barrier Manager. - * - * Directives provided are: - * - * - create a barrier - * - delete a barrier - * - wait for a barrier - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_BARRIER_H -#define _RTEMS_POSIX_BARRIER_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIXBarrier POSIX Barriers - * - * @ingroup POSIXAPI - * - * This encapsulates functionality which implements the RTEMS API - * Barrier Manager. - * - */ -/**@{**/ - -/** - * This type defines the control block used to manage each barrier. - */ - -typedef struct { - /** This is used to manage a barrier as an object. */ - Objects_Control Object; - /** This is used to implement the barrier. */ - CORE_barrier_Control Barrier; -} POSIX_Barrier_Control; - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h index fae66a6171..a1794b82fd 100644 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ b/cpukit/posix/include/rtems/posix/barrierimpl.h @@ -11,6 +11,8 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2017 embedded brains GmbH + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -19,63 +21,76 @@ #ifndef _RTEMS_POSIX_BARRIERIMPL_H #define _RTEMS_POSIX_BARRIERIMPL_H -#include -#include -#include - #include #include +#include +#include + #ifdef __cplusplus extern "C" { #endif -/** - * The following defines the information control block used to manage - * this class of objects. - */ +#define POSIX_BARRIER_MAGIC 0x1cf03773UL -extern Objects_Information _POSIX_Barrier_Information; +#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO -/** - * @brief Allocate a barrier control block. - * - * This function allocates a barrier control block from - * the inactive chain of free barrier control blocks. - */ -RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Allocate( void ) +typedef struct { + unsigned long flags; + Thread_queue_Syslock_queue Queue; + unsigned int count; + unsigned int waiting_threads; +} POSIX_Barrier_Control; + +static inline POSIX_Barrier_Control *_POSIX_Barrier_Get( + pthread_barrier_t *_barrier +) { - return (POSIX_Barrier_Control *) - _Objects_Allocate( &_POSIX_Barrier_Information ); + return (POSIX_Barrier_Control *) _barrier; } -/** - * @brief Free a barrier control block. - * - * This routine frees a barrier control block to the - * inactive chain of free barrier control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Barrier_Free ( - POSIX_Barrier_Control *the_barrier +static inline Thread_Control *_POSIX_Barrier_Queue_acquire( + POSIX_Barrier_Control *barrier, + Thread_queue_Context *queue_context ) { - _CORE_barrier_Destroy( &the_barrier->Barrier ); - _Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object ); + ISR_Level level; + Thread_Control *executing; + + _Thread_queue_Context_initialize( queue_context ); + _Thread_queue_Context_ISR_disable( queue_context, level ); + _Thread_queue_Context_set_ISR_level( queue_context, level ); + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &barrier->Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; } -RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get( - const pthread_barrier_t *barrier, - Thread_queue_Context *queue_context +static inline void _POSIX_Barrier_Queue_release( + POSIX_Barrier_Control *barrier, + Thread_queue_Context *queue_context ) { - _Thread_queue_Context_initialize( queue_context ); - return (POSIX_Barrier_Control *) _Objects_Get( - (Objects_Id) *barrier, - &queue_context->Lock_context.Lock_context, - &_POSIX_Barrier_Information + _Thread_queue_Queue_release( + &barrier->Queue.Queue, + &queue_context->Lock_context.Lock_context ); } +#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \ + do { \ + if ( \ + ( bar ) == NULL \ + || ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \ + ) { \ + return EINVAL; \ + } \ + } while ( 0 ) + #ifdef __cplusplus } #endif diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h index 6c74216dc2..dc1ef0c2f1 100644 --- a/cpukit/posix/include/rtems/posix/config.h +++ b/cpukit/posix/include/rtems/posix/config.h @@ -98,12 +98,6 @@ typedef struct { */ uint32_t maximum_semaphores; - /** - * This field contains the maximum number of POSIX API - * barriers which are configured for this application. - */ - uint32_t maximum_barriers; - /** * This field contains the maximum number of POSIX API * read/write locks which are configured for this application. diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am index d67f9face8..903591ad65 100644 --- a/cpukit/posix/preinstall.am +++ b/cpukit/posix/preinstall.am @@ -27,6 +27,10 @@ $(PROJECT_INCLUDE)/rtems/posix/sigset.h: include/rtems/posix/sigset.h $(PROJECT_ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/sigset.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/sigset.h +$(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h: include/rtems/posix/barrierimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h + $(PROJECT_INCLUDE)/rtems/posix/key.h: include/rtems/posix/key.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.h @@ -140,14 +144,6 @@ $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h: include/rtems/posix/timerimpl.h $(PR $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h -$(PROJECT_INCLUDE)/rtems/posix/barrier.h: include/rtems/posix/barrier.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.h - -$(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h: include/rtems/posix/barrierimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h - $(PROJECT_INCLUDE)/rtems/posix/rwlock.h: include/rtems/posix/rwlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.h diff --git a/cpukit/posix/src/pbarrier.c b/cpukit/posix/src/pbarrier.c deleted file mode 100644 index 8216a080b1..0000000000 --- a/cpukit/posix/src/pbarrier.c +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * - * This file initializes the POSIX Barrier Manager. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include -#include -#include - -Objects_Information _POSIX_Barrier_Information; - -/** - * @brief _POSIX_Barrier_Manager_initialization - */ -static void _POSIX_Barrier_Manager_initialization(void) -{ - _Objects_Initialize_information( - &_POSIX_Barrier_Information, /* object information table */ - OBJECTS_POSIX_API, /* object API */ - OBJECTS_POSIX_BARRIERS, /* object class */ - Configuration_POSIX_API.maximum_barriers, - /* maximum objects of this class */ - sizeof( POSIX_Barrier_Control ),/* size of this object's control block */ - true, /* true if the name is a string */ - _POSIX_PATH_MAX, /* maximum length of each object's name */ - NULL /* Proxy extraction support callout */ - ); -} - -RTEMS_SYSINIT_ITEM( - _POSIX_Barrier_Manager_initialization, - RTEMS_SYSINIT_POSIX_BARRIER, - RTEMS_SYSINIT_ORDER_MIDDLE -); diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c index 8f85762211..83d06318b5 100644 --- a/cpukit/posix/src/pbarrierdestroy.c +++ b/cpukit/posix/src/pbarrierdestroy.c @@ -9,6 +9,8 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2017 embedded brains GmbH + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -20,47 +22,23 @@ #include -/** - * This directive allows a thread to delete a barrier specified by - * the barrier id. The barrier is freed back to the inactive - * barrier chain. - * - * @param[in] barrier is the barrier id - * - * @return This method returns 0 if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -int pthread_barrier_destroy( - pthread_barrier_t *barrier -) +int pthread_barrier_destroy( pthread_barrier_t *_barrier ) { - POSIX_Barrier_Control *the_barrier; + POSIX_Barrier_Control *barrier; Thread_queue_Context queue_context; - if ( barrier == NULL ) { - return EINVAL; - } - - _Objects_Allocator_lock(); - the_barrier = _POSIX_Barrier_Get( barrier, &queue_context ); + POSIX_BARRIER_VALIDATE_OBJECT( _barrier ); - if ( the_barrier == NULL ) { - _Objects_Allocator_unlock(); - return EINVAL; - } + barrier = _POSIX_Barrier_Get( _barrier ); - _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &queue_context ); + _POSIX_Barrier_Queue_acquire( barrier, &queue_context ); - if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) { - _CORE_barrier_Release( &the_barrier->Barrier, &queue_context ); - _Objects_Allocator_unlock(); + if ( barrier->waiting_threads != 0 ) { + _POSIX_Barrier_Queue_release( barrier, &queue_context ); return EBUSY; } - _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object ); - _CORE_barrier_Release( &the_barrier->Barrier, &queue_context ); - _POSIX_Barrier_Free( the_barrier ); - _Objects_Allocator_unlock(); + barrier->flags = 0; + _POSIX_Barrier_Queue_release( barrier, &queue_context ); return 0; } diff --git a/cpukit/posix/src/pbarrierinit.c b/cpukit/posix/src/pbarrierinit.c index c14cc0cb90..1fa22cb024 100644 --- a/cpukit/posix/src/pbarrierinit.c +++ b/cpukit/posix/src/pbarrierinit.c @@ -11,6 +11,8 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2017 embedded brains GmbH + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -20,91 +22,74 @@ #include "config.h" #endif -#include -#include - -#include #include #include -/* - * pthread_barrier_init - * - * This directive creates a barrier. A barrier id is returned. - * - * Input parameters: - * barrier - pointer to barrier id - * attr - barrier attributes - * count - number of threads before automatic release - * - * Output parameters: - * barrier - barrier id - * 0 - if successful - * error code - if unsuccessful - */ +RTEMS_STATIC_ASSERT( + offsetof( POSIX_Barrier_Control, flags ) + == offsetof( pthread_barrier_t, _flags ), + POSIX_BARRIER_CONTROL_FLAGS +); + +RTEMS_STATIC_ASSERT( + offsetof( POSIX_Barrier_Control, count ) + == offsetof( pthread_barrier_t, _count ), + POSIX_BARRIER_CONTROL_COUNT +); + +RTEMS_STATIC_ASSERT( + offsetof( POSIX_Barrier_Control, waiting_threads ) + == offsetof( pthread_barrier_t, _waiting_threads ), + POSIX_BARRIER_CONTROL_WAITING_THREADS +); + +RTEMS_STATIC_ASSERT( + offsetof( POSIX_Barrier_Control, Queue ) + == offsetof( pthread_barrier_t, _Queue ), + POSIX_BARRIER_CONTROL_QUEUE +); + +RTEMS_STATIC_ASSERT( + sizeof( POSIX_Barrier_Control ) == sizeof( pthread_barrier_t ), + POSIX_BARRIER_CONTROL_SIZE +); int pthread_barrier_init( - pthread_barrier_t *barrier, + pthread_barrier_t *_barrier, const pthread_barrierattr_t *attr, unsigned int count ) { - POSIX_Barrier_Control *the_barrier; - CORE_barrier_Attributes the_attributes; - pthread_barrierattr_t my_attr; - const pthread_barrierattr_t *the_attr; + POSIX_Barrier_Control *barrier; + + barrier = _POSIX_Barrier_Get( _barrier ); /* * Error check parameters */ - if ( !barrier ) + if ( barrier == NULL ) { return EINVAL; - - if ( count == 0 ) - return EINVAL; - - /* - * If the user passed in NULL, use the default attributes - */ - if ( attr ) { - the_attr = attr; - } else { - (void) pthread_barrierattr_init( &my_attr ); - the_attr = &my_attr; } - /* - * Now start error checking the attributes that we are going to use - */ - if ( !the_attr->is_initialized ) - return EINVAL; - - if ( !_POSIX_Is_valid_pshared( the_attr->process_shared ) ) { + if ( count == 0 ) { return EINVAL; } - /* - * Convert from POSIX attributes to Core Barrier attributes - */ - the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE; - the_attributes.maximum_count = count; - - the_barrier = _POSIX_Barrier_Allocate(); + if ( attr != NULL ) { + /* + * Now start error checking the attributes that we are going to use + */ + if ( !attr->is_initialized ) + return EINVAL; - if ( !the_barrier ) { - _Objects_Allocator_unlock(); - return EAGAIN; + if ( !_POSIX_Is_valid_pshared( attr->process_shared ) ) { + return EINVAL; + } } - _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes ); - - _Objects_Open_u32( - &_POSIX_Barrier_Information, - &the_barrier->Object, - 0 - ); - - *barrier = the_barrier->Object.id; - _Objects_Allocator_unlock(); + barrier->flags = (uintptr_t) barrier ^ POSIX_BARRIER_MAGIC; + barrier->count = count; + barrier->waiting_threads = 0; + _Thread_queue_Queue_initialize( &barrier->Queue.Queue, NULL ); return 0; } diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c index 117beac553..9719112256 100644 --- a/cpukit/posix/src/pbarrierwait.c +++ b/cpukit/posix/src/pbarrierwait.c @@ -9,6 +9,8 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2017 embedded brains GmbH + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -21,32 +23,44 @@ #include #include -THREAD_QUEUE_OBJECT_ASSERT( POSIX_Barrier_Control, Barrier.Wait_queue ); - -int pthread_barrier_wait( - pthread_barrier_t *barrier -) +int pthread_barrier_wait( pthread_barrier_t *_barrier ) { - POSIX_Barrier_Control *the_barrier; + POSIX_Barrier_Control *barrier; Thread_queue_Context queue_context; - Status_Control status; + Thread_Control *executing; + unsigned int waiting_threads; - if ( barrier == NULL ) { - return EINVAL; - } + POSIX_BARRIER_VALIDATE_OBJECT( _barrier ); - the_barrier = _POSIX_Barrier_Get( barrier, &queue_context ); + barrier = _POSIX_Barrier_Get( _barrier ); - if ( the_barrier == NULL ) { - return EINVAL; - } + executing = _POSIX_Barrier_Queue_acquire( barrier, &queue_context ); + waiting_threads = barrier->waiting_threads; + ++waiting_threads; - _Thread_queue_Context_set_no_timeout( &queue_context ); - status = _CORE_barrier_Seize( - &the_barrier->Barrier, - _Thread_Executing, - true, - &queue_context - ); - return _POSIX_Get_error( status ); + if ( waiting_threads == barrier->count ) { + barrier->waiting_threads = 0; + _Thread_queue_Flush_critical( + &barrier->Queue.Queue, + POSIX_BARRIER_TQ_OPERATIONS, + _Thread_queue_Flush_default_filter, + &queue_context + ); + return PTHREAD_BARRIER_SERIAL_THREAD; + } else { + barrier->waiting_threads = waiting_threads; + _Thread_queue_Context_set_thread_state( + &queue_context, + STATES_WAITING_FOR_BARRIER + ); + _Thread_queue_Context_set_do_nothing_enqueue_callout( &queue_context ); + _Thread_queue_Context_set_no_timeout( &queue_context ); + _Thread_queue_Enqueue( + &barrier->Queue.Queue, + POSIX_BARRIER_TQ_OPERATIONS, + executing, + &queue_context + ); + return 0; + } } diff --git a/cpukit/rtems/src/rtemsobjectgetapiclassname.c b/cpukit/rtems/src/rtemsobjectgetapiclassname.c index 4d3b1cb37c..ecac3a5c5f 100644 --- a/cpukit/rtems/src/rtemsobjectgetapiclassname.c +++ b/cpukit/rtems/src/rtemsobjectgetapiclassname.c @@ -53,7 +53,6 @@ static const rtems_assoc_t rtems_object_api_posix_assoc[] = { { "Semaphore", OBJECTS_POSIX_SEMAPHORES, 0}, { "Condition Variable", OBJECTS_POSIX_CONDITION_VARIABLES, 0}, { "Timer", OBJECTS_POSIX_TIMERS, 0}, - { "Barrier", OBJECTS_POSIX_BARRIERS, 0}, { "RWLock", OBJECTS_POSIX_RWLOCKS, 0}, { "Shared Memory", OBJECTS_POSIX_SHMS, 0}, { NULL, 0, 0} diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 5fe366089e..c8bb18ae07 100755 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -2081,10 +2081,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \ rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_BARRIERS) - #define CONFIGURE_MAXIMUM_POSIX_BARRIERS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif #if !defined(CONFIGURE_MAXIMUM_POSIX_RWLOCKS) #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS \ rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) @@ -2448,7 +2444,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; #include #include #include - #include #include #include #include @@ -2571,21 +2566,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; _Configure_POSIX_Named_Object_RAM( \ _semaphores, sizeof(POSIX_Semaphore_Control) ) - /** - * This configuration parameter specifies the maximum number of - * POSIX API barriers. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_BARRIERS - #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 0 - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API barriers. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(_barriers) \ - _Configure_Object_RAM(_barriers, sizeof(POSIX_Barrier_Control) ) - /** * This configuration parameter specifies the maximum number of * POSIX API rwlocks. @@ -2842,7 +2822,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \ _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \ CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \ - _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(CONFIGURE_MAXIMUM_POSIX_BARRIERS) + \ _CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \ CONFIGURE_MAXIMUM_POSIX_RWLOCKS) + \ _CONFIGURE_MEMORY_FOR_POSIX_SHMS( \ @@ -3296,7 +3275,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS, CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES, CONFIGURE_MAXIMUM_POSIX_SEMAPHORES, - CONFIGURE_MAXIMUM_POSIX_BARRIERS, CONFIGURE_MAXIMUM_POSIX_RWLOCKS, CONFIGURE_MAXIMUM_POSIX_SHMS, CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE, @@ -3512,7 +3490,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; uint32_t POSIX_QUEUED_SIGNALS; uint32_t POSIX_MESSAGE_QUEUES; uint32_t POSIX_SEMAPHORES; - uint32_t POSIX_BARRIERS; uint32_t POSIX_RWLOCKS; uint32_t POSIX_SHMS; #endif @@ -3566,7 +3543,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ), _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ), - _CONFIGURE_MEMORY_FOR_POSIX_BARRIERS( CONFIGURE_MAXIMUM_POSIX_BARRIERS ), _CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( CONFIGURE_MAXIMUM_POSIX_RWLOCKS ), _CONFIGURE_MEMORY_FOR_POSIX_SHMS( CONFIGURE_MAXIMUM_POSIX_SHMS ), _CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ), @@ -3638,7 +3614,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; (CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \ (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \ (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_BARRIERS != 0) || \ (CONFIGURE_MAXIMUM_POSIX_RWLOCKS != 0) || \ (CONFIGURE_MAXIMUM_POSIX_SHMS != 0) || \ defined(CONFIGURE_POSIX_INIT_THREAD_TABLE)) diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index ef725bea96..a877e83ffc 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -20,6 +20,7 @@ #endif #include +#include #include #include @@ -44,8 +45,33 @@ RTEMS_STATIC_ASSERT( POSIX_SEMAPHORE_MAGIC != HEAP_FREE_PATTERN, POSIX_SEMAPHORE_MAGIC_4 ); +RTEMS_STATIC_ASSERT( + POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_0, + POSIX_BARRIER_MAGIC_0 +); +RTEMS_STATIC_ASSERT( + POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_1, + POSIX_BARRIER_MAGIC_1 +); +RTEMS_STATIC_ASSERT( + POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_0, + POSIX_BARRIER_MAGIC_2 +); +RTEMS_STATIC_ASSERT( + POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_1, + POSIX_BARRIER_MAGIC_3 +); +RTEMS_STATIC_ASSERT( + POSIX_BARRIER_MAGIC != HEAP_FREE_PATTERN, + POSIX_BARRIER_MAGIC_4 +); #endif +RTEMS_STATIC_ASSERT( + POSIX_SEMAPHORE_MAGIC != POSIX_BARRIER_MAGIC, + POSIX_SEMAPHORE_MAGIC_5 +); + void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno ) { uint32_t code = ( domain << 8 ) | ( ( uint32_t ) eno & 0xffU ); diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h index cd36ce6316..e68035d338 100644 --- a/cpukit/score/include/rtems/score/objectimpl.h +++ b/cpukit/score/include/rtems/score/objectimpl.h @@ -91,7 +91,6 @@ typedef enum { OBJECTS_POSIX_SEMAPHORES = 7, OBJECTS_POSIX_CONDITION_VARIABLES = 8, OBJECTS_POSIX_TIMERS = 9, - OBJECTS_POSIX_BARRIERS = 10, OBJECTS_POSIX_RWLOCKS = 11, OBJECTS_POSIX_SHMS = 12 } Objects_POSIX_API; diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h index bd4778ab5c..29ad24dc2f 100644 --- a/cpukit/score/include/rtems/sysinit.h +++ b/cpukit/score/include/rtems/sysinit.h @@ -52,7 +52,6 @@ extern "C" { #define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE 000364 #define RTEMS_SYSINIT_POSIX_SEMAPHORE 000365 #define RTEMS_SYSINIT_POSIX_TIMER 000366 -#define RTEMS_SYSINIT_POSIX_BARRIER 000367 #define RTEMS_SYSINIT_POSIX_RWLOCK 000368 #define RTEMS_SYSINIT_POSIX_SHM 000369 #define RTEMS_SYSINIT_POSIX_KEYS 00036a -- cgit v1.2.3