forked from Imagelibrary/rtems
2006-09-25 Joel Sherrill <joel.sherrill@oarcorp.com>
* rtems/Makefile.am, rtems/preinstall.am, rtems/include/rtems.h, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/config.h, rtems/inline/rtems/rtems/attr.inl, rtems/macros/rtems/rtems/attr.inl: Add Classic API Barriers. * rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/barriermp.h, rtems/inline/rtems/rtems/barrier.inl, rtems/macros/rtems/rtems/barrier.inl, rtems/src/barrier.c, rtems/src/barriercreate.c, rtems/src/barrierdelete.c, rtems/src/barrierident.c, rtems/src/barrierrelease.c, rtems/src/barriertranslatereturncode.c, rtems/src/barrierwait.c: New files.
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
2006-09-25 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* rtems/Makefile.am, rtems/preinstall.am, rtems/include/rtems.h,
|
||||
rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/config.h,
|
||||
rtems/inline/rtems/rtems/attr.inl, rtems/macros/rtems/rtems/attr.inl:
|
||||
Add Classic API Barriers.
|
||||
* rtems/include/rtems/rtems/barrier.h,
|
||||
rtems/include/rtems/rtems/barriermp.h,
|
||||
rtems/inline/rtems/rtems/barrier.inl,
|
||||
rtems/macros/rtems/rtems/barrier.inl, rtems/src/barrier.c,
|
||||
rtems/src/barriercreate.c, rtems/src/barrierdelete.c,
|
||||
rtems/src/barrierident.c, rtems/src/barrierrelease.c,
|
||||
rtems/src/barriertranslatereturncode.c, rtems/src/barrierwait.c:
|
||||
New files.
|
||||
|
||||
2006-09-25 Joel Sherrill <joel@oarcorp.com>
|
||||
|
||||
* score/Makefile.am, score/preinstall.am,
|
||||
|
||||
@@ -18,7 +18,8 @@ include_HEADERS = include/rtems.h
|
||||
include_rtems_rtemsdir = $(includedir)/rtems/rtems
|
||||
|
||||
include_rtems_rtems_HEADERS = include/rtems/rtems/asr.h \
|
||||
include/rtems/rtems/attr.h include/rtems/rtems/cache.h \
|
||||
include/rtems/rtems/attr.h include/rtems/rtems/barrier.h \
|
||||
include/rtems/rtems/cache.h \
|
||||
include/rtems/rtems/clock.h include/rtems/rtems/config.h \
|
||||
include/rtems/rtems/dpmem.h include/rtems/rtems/event.h \
|
||||
include/rtems/rtems/eventset.h include/rtems/rtems/intr.h \
|
||||
@@ -41,7 +42,8 @@ endif
|
||||
|
||||
if INLINE
|
||||
include_rtems_rtems_HEADERS += inline/rtems/rtems/asr.inl \
|
||||
inline/rtems/rtems/attr.inl inline/rtems/rtems/dpmem.inl \
|
||||
inline/rtems/rtems/attr.inl inline/rtems/rtems/barrier.inl \
|
||||
inline/rtems/rtems/dpmem.inl \
|
||||
inline/rtems/rtems/event.inl inline/rtems/rtems/eventset.inl \
|
||||
inline/rtems/rtems/message.inl inline/rtems/rtems/modes.inl \
|
||||
inline/rtems/rtems/options.inl inline/rtems/rtems/part.inl \
|
||||
@@ -51,7 +53,8 @@ include_rtems_rtems_HEADERS += inline/rtems/rtems/asr.inl \
|
||||
inline/rtems/rtems/timer.inl
|
||||
else
|
||||
include_rtems_rtems_HEADERS += macros/rtems/rtems/asr.inl \
|
||||
macros/rtems/rtems/attr.inl macros/rtems/rtems/dpmem.inl \
|
||||
macros/rtems/rtems/attr.inl macros/rtems/rtems/barrier.inl \
|
||||
macros/rtems/rtems/dpmem.inl \
|
||||
macros/rtems/rtems/event.inl macros/rtems/rtems/eventset.inl \
|
||||
macros/rtems/rtems/message.inl macros/rtems/rtems/modes.inl \
|
||||
macros/rtems/rtems/options.inl macros/rtems/rtems/part.inl \
|
||||
@@ -80,8 +83,13 @@ librtems_a_SOURCES += src/ratemon.c src/ratemoncancel.c src/ratemoncreate.c \
|
||||
## INTR_C_FILES
|
||||
librtems_a_SOURCES += src/intr.c src/intrbody.c src/intrcatch.c
|
||||
|
||||
## BARRIER_C_FILES
|
||||
librtems_a_SOURCES += src/barrier.c src/barriercreate.c src/barrierdelete.c \
|
||||
src/barrierident.c src/barriertranslatereturncode.c src/barrierwait.c
|
||||
|
||||
## CLOCK_C_FILES
|
||||
librtems_a_SOURCES += src/rtclock.c src/clockget.c src/clockset.c src/clocktick.c
|
||||
librtems_a_SOURCES += src/rtclock.c src/clockget.c src/clockset.c \
|
||||
src/clocktick.c
|
||||
|
||||
## TIMER_C_FILES
|
||||
librtems_a_SOURCES += src/rtemstimer.c src/timercancel.c src/timercreate.c \
|
||||
|
||||
@@ -46,6 +46,7 @@ extern "C" {
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/tasks.h>
|
||||
#include <rtems/rtems/intr.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/rtems/cache.h>
|
||||
#include <rtems/rtems/clock.h>
|
||||
#include <rtems/extension.h>
|
||||
|
||||
@@ -31,28 +31,35 @@ typedef uint32_t rtems_attribute;
|
||||
|
||||
#define RTEMS_DEFAULT_ATTRIBUTES 0x00000000
|
||||
|
||||
#define RTEMS_NO_FLOATING_POINT 0x00000000 /* don't use FP HW */
|
||||
#define RTEMS_FLOATING_POINT 0x00000001 /* utilize coprocessor */
|
||||
|
||||
#define RTEMS_LOCAL 0x00000000 /* local resource */
|
||||
#define RTEMS_GLOBAL 0x00000002 /* global resource */
|
||||
|
||||
#define RTEMS_FIFO 0x00000000 /* process RTEMS_FIFO */
|
||||
#define RTEMS_PRIORITY 0x00000004 /* process by priority */
|
||||
|
||||
/* RTEMS Task Specific Attributes */
|
||||
#define RTEMS_NO_FLOATING_POINT 0x00000000 /* don't use FP HW */
|
||||
#define RTEMS_FLOATING_POINT 0x00000001 /* utilize coprocessor */
|
||||
|
||||
/* RTEMS Semaphore Specific Attributes */
|
||||
#define RTEMS_SEMAPHORE_CLASS 0x00000030 /* mask */
|
||||
#define RTEMS_COUNTING_SEMAPHORE 0x00000000
|
||||
#define RTEMS_BINARY_SEMAPHORE 0x00000010
|
||||
#define RTEMS_SIMPLE_BINARY_SEMAPHORE 0x00000020
|
||||
|
||||
#define RTEMS_NO_INHERIT_PRIORITY 0x00000000
|
||||
#define RTEMS_INHERIT_PRIORITY 0x00000040
|
||||
#define RTEMS_NO_INHERIT_PRIORITY 0x00000000
|
||||
#define RTEMS_INHERIT_PRIORITY 0x00000040
|
||||
|
||||
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
||||
#define RTEMS_PRIORITY_CEILING 0x00000080
|
||||
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
|
||||
#define RTEMS_PRIORITY_CEILING 0x00000080
|
||||
|
||||
#define RTEMS_APPLICATION_TASK 0x00000000
|
||||
#define RTEMS_SYSTEM_TASK 0x00000100
|
||||
/* RTEMS Barrier Specific Attributes */
|
||||
#define RTEMS_BARRIER_AUTOMATIC_RELEASE 0x00000010
|
||||
#define RTEMS_BARRIER_MANUAL_RELEASE 0x00000000
|
||||
|
||||
/* RTEMS Internal Task Specific Attributes */
|
||||
#define RTEMS_APPLICATION_TASK 0x00000000
|
||||
#define RTEMS_SYSTEM_TASK 0x00008000
|
||||
|
||||
|
||||
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||
|
||||
195
cpukit/rtems/include/rtems/rtems/barrier.h
Normal file
195
cpukit/rtems/include/rtems/rtems/barrier.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @file rtems/rtems/barrier.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* This include file contains all the constants and structures associated
|
||||
* with the Barrier Manager.
|
||||
*
|
||||
* Directives provided are:
|
||||
*
|
||||
* + create a barrier
|
||||
* + get an ID of a barrier
|
||||
* + delete a barrier
|
||||
* + wait for a barrier
|
||||
* + signal a barrier
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_RTEMS_BARRIER_H
|
||||
#define _RTEMS_RTEMS_BARRIER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems/rtems/types.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attr.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/corebarrier.h>
|
||||
|
||||
/**
|
||||
* 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 specify the attributes of a barrier. */
|
||||
rtems_attribute attribute_set;
|
||||
/** This is used to implement the barrier. */
|
||||
CORE_barrier_Control Barrier;
|
||||
} Barrier_Control;
|
||||
|
||||
/**
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
RTEMS_EXTERN Objects_Information _Barrier_Information;
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Manager_initialization
|
||||
*
|
||||
* This routine performs the initialization necessary for this manager.
|
||||
*
|
||||
* @param[in] maximum_barriers is the total number of barriers allowed to
|
||||
* concurrently be active in the system.
|
||||
*/
|
||||
|
||||
void _Barrier_Manager_initialization(
|
||||
uint32_t maximum_barriers
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief rtems_barrier_create
|
||||
*
|
||||
* This routine implements the rtems_barrier_create directive. The
|
||||
* barrier will have the name name. The starting count for
|
||||
* the barrier is count. The attribute_set determines if
|
||||
* the barrier is global or local and the thread queue
|
||||
* discipline. It returns the id of the created barrier in ID.
|
||||
*
|
||||
* @param[in] name is the name of this barrier instance.
|
||||
* @param[in] attribute_set specifies the attributes of this barrier instance.
|
||||
* @param[in] maximum_waiters is the maximum number of threads which will
|
||||
* be allowed to concurrently wait at the barrier.
|
||||
* @param[out] id will contain the id of this barrier.
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_create(
|
||||
rtems_name name,
|
||||
rtems_attribute attribute_set,
|
||||
uint32_t maximum_waiters,
|
||||
rtems_id *id
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief rtems_barrier_ident
|
||||
*
|
||||
* This routine implements the rtems_barrier_ident directive.
|
||||
* This directive returns the barrier ID associated with name.
|
||||
* If more than one barrier is named name, then the barrier
|
||||
* to which the ID belongs is arbitrary. node indicates the
|
||||
* extent of the search for the ID of the barrier named name.
|
||||
* The search can be limited to a particular node or allowed to
|
||||
* encompass all nodes.
|
||||
*
|
||||
* @param[in] name is the name of this barrier instance.
|
||||
* @param[out] id will contain the id of this barrier.
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_ident(
|
||||
rtems_name name,
|
||||
rtems_id *id
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief rtems_barrier_delete
|
||||
*
|
||||
* This routine implements the rtems_barrier_delete directive. The
|
||||
* barrier indicated by @a id is deleted.
|
||||
*
|
||||
* @param[in] id indicates the barrier to delete
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
rtems_status_code rtems_barrier_delete(
|
||||
rtems_id id
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief rtems_barrier_wait
|
||||
*
|
||||
* This routine implements the rtems_barrier_wait directive. It
|
||||
* attempts to wait at the barrier associated with @a id. The calling task
|
||||
* may block waiting for the barrier with an optional timeout of @a timeout
|
||||
* clock ticks.
|
||||
*
|
||||
* @param[in] id indicates the barrier to wait at.
|
||||
* @param[in] option_set indicates if the caller is willing to wait.
|
||||
* @param[in] timeout is the maximum length of time in ticks the calling
|
||||
* thread is willing to block.
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
rtems_status_code rtems_barrier_wait(
|
||||
rtems_id id,
|
||||
rtems_interval timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief rtems_barrier_release
|
||||
*
|
||||
* This routine implements the rtems_barrier_release directive. It
|
||||
* unblocks all of the threads waiting on the barrier associated with
|
||||
* @a id. The number of threads unblocked is returns in @a unblocked.
|
||||
*
|
||||
*
|
||||
* @param[in] id indicates the barrier to wait at.
|
||||
* @param[out] unblocked will contain the number of threads unblocked.
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
rtems_status_code rtems_barrier_release(
|
||||
rtems_id id,
|
||||
uint32_t *unblocked
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Translate SuperCore Barrier Status Code to RTEMS Status Code
|
||||
*
|
||||
* This function returns a RTEMS status code based on the barrier
|
||||
* status code specified.
|
||||
*
|
||||
* @param[in] the_status is the SuperCore Barrier status to translate.
|
||||
*
|
||||
* @return a status code indicating success or the reason for failure.
|
||||
*/
|
||||
rtems_status_code _Barrier_Translate_core_barrier_return_code (
|
||||
CORE_barrier_Status the_status
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/rtems/barrier.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
141
cpukit/rtems/include/rtems/rtems/barriermp.h
Normal file
141
cpukit/rtems/include/rtems/rtems/barriermp.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @file rtems/rtems/barriermp.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* This include file contains all the constants and structures associated
|
||||
* with the Multiprocessing Support in the Barrier Manager.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_RTEMS_SEMMP_H
|
||||
#define _RTEMS_RTEMS_SEMMP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems/score/mppkt.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
|
||||
/**
|
||||
* The following enumerated type defines the list of
|
||||
* remote barrier operations.
|
||||
*/
|
||||
typedef enum {
|
||||
BARRIER_MP_ANNOUNCE_CREATE = 0,
|
||||
BARRIER_MP_ANNOUNCE_DELETE = 1,
|
||||
BARRIER_MP_EXTRACT_PROXY = 2,
|
||||
BARRIER_MP_WAIT_REQUEST = 3,
|
||||
BARRIER_MP_WAIT_RESPONSE = 4,
|
||||
BARRIER_MP_RELEASE_REQUEST = 5,
|
||||
BARRIER_MP_RELEASE_RESPONSE = 6
|
||||
} Barrier_MP_Remote_operations;
|
||||
|
||||
/**
|
||||
* The following data structure defines the packet used to perform
|
||||
* remote barrier operations.
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_packet_prefix Prefix;
|
||||
Barrier_MP_Remote_operations operation;
|
||||
rtems_name name;
|
||||
rtems_option option_set;
|
||||
Objects_Id proxy_id;
|
||||
} Barrier_MP_Packet;
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Send_process_packet
|
||||
*
|
||||
* This routine performs a remote procedure call so that a
|
||||
* process operation can be performed on another node.
|
||||
*/
|
||||
void _Barrier_MP_Send_process_packet (
|
||||
Barrier_MP_Remote_operations operation,
|
||||
Objects_Id barrier_id,
|
||||
rtems_name name,
|
||||
Objects_Id proxy_id
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Send_request_packet
|
||||
*
|
||||
* This routine performs a remote procedure call so that a
|
||||
* directive operation can be initiated on another node.
|
||||
*/
|
||||
rtems_status_code _Barrier_MP_Send_request_packet (
|
||||
Barrier_MP_Remote_operations operation,
|
||||
Objects_Id barrier_id,
|
||||
rtems_interval timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Send_response_packet
|
||||
*
|
||||
* This routine performs a remote procedure call so that a
|
||||
* directive can be performed on another node.
|
||||
*/
|
||||
|
||||
void _Barrier_MP_Send_response_packet (
|
||||
Barrier_MP_Remote_operations operation,
|
||||
Objects_Id barrier_id,
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Process_packet
|
||||
*
|
||||
* This routine performs the actions specific to this package for
|
||||
* the request from another node.
|
||||
*/
|
||||
void _Barrier_MP_Process_packet (
|
||||
rtems_packet_prefix *the_packet_prefix
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Send_object_was_deleted
|
||||
*
|
||||
* This routine is invoked indirectly by the thread queue
|
||||
* when a proxy has been removed from the thread queue and
|
||||
* the remote node must be informed of this.
|
||||
*/
|
||||
void _Barrier_MP_Send_object_was_deleted (
|
||||
Thread_Control *the_proxy
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Send_extract_proxy
|
||||
*
|
||||
* This routine is invoked when a task is deleted and it
|
||||
* has a proxy which must be removed from a thread queue and
|
||||
* the remote node must be informed of this.
|
||||
*/
|
||||
void _Barrier_MP_Send_extract_proxy (
|
||||
void *argument
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Barrier_MP_Get_packet
|
||||
*
|
||||
* This function is used to obtain a barrier mp packet.
|
||||
*/
|
||||
Barrier_MP_Packet *_Barrier_MP_Get_packet ( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of file */
|
||||
@@ -6,7 +6,7 @@
|
||||
* This include file contains the table of user defined configuration
|
||||
* parameters specific for the RTEMS API.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -44,6 +44,7 @@ typedef struct {
|
||||
uint32_t maximum_regions;
|
||||
uint32_t maximum_ports;
|
||||
uint32_t maximum_periods;
|
||||
uint32_t maximum_barriers;
|
||||
uint32_t number_of_initialization_tasks;
|
||||
rtems_initialization_tasks_table *User_initialization_tasks_table;
|
||||
} rtems_api_configuration_table;
|
||||
|
||||
@@ -194,6 +194,23 @@ RTEMS_INLINE_ROUTINE boolean _Attributes_Is_priority_ceiling(
|
||||
return ( attribute_set & RTEMS_PRIORITY_CEILING );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Attributes_Is_barrier_automatic
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function returns TRUE if the barrier automatic release
|
||||
* attribute is enabled in the attribute_set and FALSE otherwise.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE boolean _Attributes_Is_barrier_automatic(
|
||||
rtems_attribute attribute_set
|
||||
)
|
||||
{
|
||||
return ( attribute_set & RTEMS_BARRIER_AUTOMATIC_RELEASE );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Attributes_Is_system_task
|
||||
|
||||
79
cpukit/rtems/inline/rtems/rtems/barrier.inl
Normal file
79
cpukit/rtems/inline/rtems/rtems/barrier.inl
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file rtems/rtems/barrier.inl
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the static inlin implementation of the inlined
|
||||
* routines from the Barrier Manager.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_RTEMS_BARRIER_INL
|
||||
#define _RTEMS_RTEMS_BARRIER_INL
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Allocate
|
||||
*
|
||||
* This function allocates a barrier control block from
|
||||
* the inactive chain of free barrier control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Allocate( void )
|
||||
{
|
||||
return (Barrier_Control *) _Objects_Allocate( &_Barrier_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Free
|
||||
*
|
||||
* This routine frees a barrier control block to the
|
||||
* inactive chain of free barrier control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Barrier_Free (
|
||||
Barrier_Control *the_barrier
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_Barrier_Information, &the_barrier->Object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Get
|
||||
*
|
||||
* This function maps barrier IDs to barrier control blocks.
|
||||
* If ID corresponds to a local barrier, then it returns
|
||||
* the_barrier control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. if the barrier ID is global and
|
||||
* resides on a remote node, then location is set to OBJECTS_REMOTE,
|
||||
* and the_barrier is undefined. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the_barrier is undefined.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get (
|
||||
Objects_Id id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (Barrier_Control *)
|
||||
_Objects_Get( &_Barrier_Information, id, location );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Is_null
|
||||
*
|
||||
* This function returns TRUE if the_barrier is NULL and FALSE otherwise.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE boolean _Barrier_Is_null (
|
||||
Barrier_Control *the_barrier
|
||||
)
|
||||
{
|
||||
return ( the_barrier == NULL );
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -109,6 +109,15 @@
|
||||
#define _Attributes_Is_priority_ceiling( _attribute_set ) \
|
||||
( (_attribute_set) & RTEMS_PRIORITY_CEILING )
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Attributes_Is_barrier_automatic
|
||||
*
|
||||
*/
|
||||
|
||||
#define _Attributes_Is_barrier_automatic( _attribute_set ) \
|
||||
( (_attribute_set) & RTEMS_BARRIER_AUTOMATIC_RELEASE )
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Attributes_Is_system_task
|
||||
|
||||
49
cpukit/rtems/macros/rtems/rtems/barrier.inl
Normal file
49
cpukit/rtems/macros/rtems/rtems/barrier.inl
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file rtems/rtems/barrier.inl
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the macro implementation of the inlined
|
||||
* routines from the Barrier Manager.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_RTEMS_BARRIER_INL
|
||||
#define _RTEMS_RTEMS_BARRIER_INL
|
||||
|
||||
/*
|
||||
* _Barrier_Allocate
|
||||
*/
|
||||
#define _Barrier_Allocate() \
|
||||
(Barrier_Control *) _Objects_Allocate( &_Barrier_Information )
|
||||
|
||||
/*
|
||||
* _Barrier_Free
|
||||
*/
|
||||
#define _Barrier_Free( _the_barrier ) \
|
||||
_Objects_Free( &_Barrier_Information, &(_the_barrier)->Object )
|
||||
|
||||
/*
|
||||
* _Barrier_Get
|
||||
*/
|
||||
|
||||
#define _Barrier_Get( _id, _location ) \
|
||||
(Barrier_Control *) \
|
||||
_Objects_Get( &_Barrier_Information, (_id), (_location) )
|
||||
|
||||
/*
|
||||
* _Barrier_Is_null
|
||||
*/
|
||||
#define _Barrier_Is_null( _the_barrier ) \
|
||||
( (_the_barrier) == NULL )
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -35,6 +35,10 @@ $(PROJECT_INCLUDE)/rtems/rtems/attr.h: include/rtems/rtems/attr.h $(PROJECT_INCL
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/attr.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/attr.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/barrier.h: include/rtems/rtems/barrier.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/barrier.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/barrier.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/cache.h: include/rtems/rtems/cache.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/cache.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/cache.h
|
||||
@@ -161,6 +165,10 @@ $(PROJECT_INCLUDE)/rtems/rtems/attr.inl: inline/rtems/rtems/attr.inl $(PROJECT_I
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/attr.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/attr.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/barrier.inl: inline/rtems/rtems/barrier.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/barrier.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/barrier.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl: inline/rtems/rtems/dpmem.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl
|
||||
@@ -226,6 +234,10 @@ $(PROJECT_INCLUDE)/rtems/rtems/attr.inl: macros/rtems/rtems/attr.inl $(PROJECT_I
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/attr.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/attr.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/barrier.inl: macros/rtems/rtems/barrier.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/barrier.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/barrier.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl: macros/rtems/rtems/dpmem.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/dpmem.inl
|
||||
|
||||
66
cpukit/rtems/src/barrier.c
Normal file
66
cpukit/rtems/src/barrier.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Barrier Manager
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This package is the implementation of the Barrier Manager.
|
||||
*
|
||||
* Directives provided are:
|
||||
*
|
||||
* + create a barrier
|
||||
* + get an ID of a barrier
|
||||
* + delete a barrier
|
||||
* + acquire a barrier
|
||||
* + release a barrier
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
#include <rtems/score/mpci.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief _Barrier_Manager_initialization
|
||||
*
|
||||
* Input parameters:
|
||||
* maximum_barriers - maximum configured barriers
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
void _Barrier_Manager_initialization(
|
||||
uint32_t maximum_barriers
|
||||
)
|
||||
{
|
||||
_Objects_Initialize_information(
|
||||
&_Barrier_Information, /* object information table */
|
||||
OBJECTS_CLASSIC_API, /* object API */
|
||||
OBJECTS_RTEMS_BARRIERS, /* object class */
|
||||
maximum_barriers, /* maximum objects of this class */
|
||||
sizeof( Barrier_Control ), /* size of this object's control block */
|
||||
FALSE, /* TRUE if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH /* maximum length of an object name */
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
,
|
||||
FALSE, /* TRUE if this is a global object class */
|
||||
NULL /* Proxy extraction support callout */
|
||||
#endif
|
||||
);
|
||||
}
|
||||
92
cpukit/rtems/src/barriercreate.c
Normal file
92
cpukit/rtems/src/barriercreate.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Barrier Manager -- Create a Barrier Instance
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attr.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
|
||||
/*
|
||||
* rtems_barrier_create
|
||||
*
|
||||
* This directive creates a barrier. A barrier id is returned.
|
||||
*
|
||||
* Input parameters:
|
||||
* name - user defined barrier name
|
||||
* attribute_set - barrier attributes
|
||||
* maximum_waiters - number of threads before automatic release
|
||||
* priority_ceiling - barrier's ceiling priority
|
||||
* id - pointer to barrier id
|
||||
*
|
||||
* Output parameters:
|
||||
* id - barrier id
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_create(
|
||||
rtems_name name,
|
||||
rtems_attribute attribute_set,
|
||||
uint32_t maximum_waiters,
|
||||
rtems_id *id
|
||||
)
|
||||
{
|
||||
Barrier_Control *the_barrier;
|
||||
CORE_barrier_Attributes the_attributes;
|
||||
|
||||
if ( !rtems_is_name_valid( name ) )
|
||||
return RTEMS_INVALID_NAME;
|
||||
|
||||
if ( !id )
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
|
||||
/* Initialize core barrier attributes */
|
||||
if ( _Attributes_Is_barrier_automatic( attribute_set ) ) {
|
||||
the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
|
||||
if ( maximum_waiters == 0 )
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
} else
|
||||
the_attributes.discipline = CORE_BARRIER_MANUAL_RELEASE;
|
||||
the_attributes.maximum_count = maximum_waiters;
|
||||
|
||||
_Thread_Disable_dispatch(); /* prevents deletion */
|
||||
|
||||
the_barrier = _Barrier_Allocate();
|
||||
|
||||
if ( !the_barrier ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_TOO_MANY;
|
||||
}
|
||||
|
||||
the_barrier->attribute_set = attribute_set;
|
||||
|
||||
_CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
|
||||
|
||||
_Objects_Open(
|
||||
&_Barrier_Information,
|
||||
&the_barrier->Object,
|
||||
(Objects_Name) name
|
||||
);
|
||||
|
||||
*id = the_barrier->Object.id;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
71
cpukit/rtems/src/barrierdelete.c
Normal file
71
cpukit/rtems/src/barrierdelete.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Barrier Manager -- Delete a Barrier
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/score/states.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/threadq.h>
|
||||
|
||||
/*
|
||||
* rtems_barrier_delete
|
||||
*
|
||||
* This directive allows a thread to delete a barrier specified by
|
||||
* the barrier id. The barrier is freed back to the inactive
|
||||
* barrier chain.
|
||||
*
|
||||
* Input parameters:
|
||||
* id - barrier id
|
||||
*
|
||||
* Output parameters:
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_delete(
|
||||
rtems_id id
|
||||
)
|
||||
{
|
||||
Barrier_Control *the_barrier;
|
||||
Objects_Locations location;
|
||||
|
||||
the_barrier = _Barrier_Get( id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_barrier_Flush(
|
||||
&the_barrier->Barrier,
|
||||
NULL,
|
||||
CORE_BARRIER_WAS_DELETED
|
||||
);
|
||||
|
||||
_Objects_Close( &_Barrier_Information, &the_barrier->Object );
|
||||
|
||||
_Barrier_Free( the_barrier );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
56
cpukit/rtems/src/barrierident.c
Normal file
56
cpukit/rtems/src/barrierident.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Barrier Manager Name to ID
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
|
||||
/*
|
||||
* rtems_barrier_ident
|
||||
*
|
||||
* This directive returns the system ID associated with
|
||||
* the barrier name.
|
||||
*
|
||||
* Input parameters:
|
||||
* name - user defined barrier name
|
||||
* id - pointer to barrier id
|
||||
*
|
||||
* Output parameters:
|
||||
* *id - barrier id
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_ident(
|
||||
rtems_name name,
|
||||
rtems_id *id
|
||||
)
|
||||
{
|
||||
Objects_Name_or_id_lookup_errors status;
|
||||
|
||||
status = _Objects_Name_to_id(
|
||||
&_Barrier_Information,
|
||||
(Objects_Name) name,
|
||||
OBJECTS_SEARCH_LOCAL_NODE,
|
||||
id
|
||||
);
|
||||
|
||||
return _Status_Object_name_errors_to_status[ status ];
|
||||
}
|
||||
66
cpukit/rtems/src/barrierrelease.c
Normal file
66
cpukit/rtems/src/barrierrelease.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Barrier Manager -- Release Tasks Waitng at a Barrier
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/threadq.h>
|
||||
|
||||
/*
|
||||
* rtems_barrier_release
|
||||
*
|
||||
* This directive releases all threads waiting at a barrier.
|
||||
*
|
||||
* Input parameters:
|
||||
* id - barrier id
|
||||
* released - pointer to number of threads unblocked
|
||||
*
|
||||
* Output parameters:
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
* *released - number of threads unblocked
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_release(
|
||||
rtems_id id,
|
||||
rtems_unsigned32 *released
|
||||
)
|
||||
{
|
||||
Barrier_Control *the_barrier;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !released )
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
|
||||
the_barrier = _Barrier_Get( id, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
*released = _CORE_barrier_Release( &the_barrier->Barrier, id, NULL );
|
||||
_Thread_Enable_dispatch();
|
||||
return _Barrier_Translate_core_barrier_return_code(
|
||||
_Thread_Executing->Wait.return_code );
|
||||
|
||||
}
|
||||
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
49
cpukit/rtems/src/barriertranslatereturncode.c
Normal file
49
cpukit/rtems/src/barriertranslatereturncode.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Barrier Manager -- Translate SuperCore Status
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
|
||||
/*
|
||||
* _Barrier_Translate_core_barrier_return_code
|
||||
*
|
||||
* Input parameters:
|
||||
* the_barrier_status - barrier status code to translate
|
||||
*
|
||||
* Output parameters:
|
||||
* rtems status code - translated RTEMS status code
|
||||
*
|
||||
*/
|
||||
|
||||
rtems_status_code _Barrier_Translate_core_barrier_return_code_[] = {
|
||||
RTEMS_SUCCESSFUL, /* CORE_BARRIER_STATUS_SUCCESSFUL */
|
||||
RTEMS_SUCCESSFUL, /* CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED */
|
||||
RTEMS_OBJECT_WAS_DELETED, /* CORE_BARRIER_WAS_DELETED */
|
||||
RTEMS_TIMEOUT /* CORE_BARRIER_TIMEOUT */
|
||||
};
|
||||
|
||||
|
||||
rtems_status_code _Barrier_Translate_core_barrier_return_code (
|
||||
CORE_barrier_Status the_barrier_status
|
||||
)
|
||||
{
|
||||
if ( the_barrier_status > CORE_BARRIER_TIMEOUT )
|
||||
return RTEMS_INTERNAL_ERROR;
|
||||
return _Barrier_Translate_core_barrier_return_code_[the_barrier_status];
|
||||
}
|
||||
67
cpukit/rtems/src/barrierwait.c
Normal file
67
cpukit/rtems/src/barrierwait.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Barrier Manager -- Wait at a Barrier
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/threadq.h>
|
||||
|
||||
/*
|
||||
* rtems_barrier_wait
|
||||
*
|
||||
* This directive allows a thread to wait at a barrier.
|
||||
*
|
||||
* Input parameters:
|
||||
* id - barrier id
|
||||
* timeout - number of ticks to wait (0 means wait forever)
|
||||
*
|
||||
* Output parameters:
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_barrier_wait(
|
||||
rtems_id id,
|
||||
rtems_interval timeout
|
||||
)
|
||||
{
|
||||
Barrier_Control *the_barrier;
|
||||
Objects_Locations location;
|
||||
|
||||
the_barrier = _Barrier_Get( id, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_barrier_Wait(
|
||||
&the_barrier->Barrier,
|
||||
id,
|
||||
TRUE,
|
||||
timeout,
|
||||
NULL
|
||||
);
|
||||
return _Barrier_Translate_core_barrier_return_code(
|
||||
_Thread_Executing->Wait.return_code );
|
||||
|
||||
}
|
||||
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
Reference in New Issue
Block a user