mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 06:08:20 +00:00
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/termios.c, posix/Makefile.am, posix/preinstall.am, posix/include/rtems/posix/config.h, posix/include/rtems/posix/time.h, sapi/src/posixapi.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/corerwlock.h, score/include/rtems/score/threadq.h, score/src/corerwlockobtainread.c, score/src/threadqenqueue.c, score/src/threadqtimeout.c: Adding POSIX barriers, POSIX spinlocks, and partial implementation of POSIX rwlocks. * posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/spinlock.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/spinlock.inl, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/pbarrier.c, posix/src/pbarrierdestroy.c, posix/src/pbarrierinit.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlock.c, posix/src/prwlockdestroy.c, posix/src/prwlockinit.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspin.c, posix/src/pspindestroy.c, posix/src/pspininit.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c: New files.
This commit is contained in:
@@ -1,3 +1,36 @@
|
||||
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* libcsupport/src/termios.c, posix/Makefile.am, posix/preinstall.am,
|
||||
posix/include/rtems/posix/config.h, posix/include/rtems/posix/time.h,
|
||||
sapi/src/posixapi.c, score/Makefile.am, score/preinstall.am,
|
||||
score/include/rtems/score/corerwlock.h,
|
||||
score/include/rtems/score/threadq.h,
|
||||
score/src/corerwlockobtainread.c, score/src/threadqenqueue.c,
|
||||
score/src/threadqtimeout.c: Adding POSIX barriers, POSIX spinlocks,
|
||||
and partial implementation of POSIX rwlocks.
|
||||
* posix/include/rtems/posix/barrier.h,
|
||||
posix/include/rtems/posix/rwlock.h,
|
||||
posix/include/rtems/posix/spinlock.h,
|
||||
posix/inline/rtems/posix/barrier.inl,
|
||||
posix/inline/rtems/posix/rwlock.inl,
|
||||
posix/inline/rtems/posix/spinlock.inl,
|
||||
posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c,
|
||||
posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c,
|
||||
posix/src/pbarrier.c, posix/src/pbarrierdestroy.c,
|
||||
posix/src/pbarrierinit.c, posix/src/pbarriertranslatereturncode.c,
|
||||
posix/src/pbarrierwait.c, posix/src/prwlock.c,
|
||||
posix/src/prwlockdestroy.c, posix/src/prwlockinit.c,
|
||||
posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c,
|
||||
posix/src/prwlocktimedwrlock.c,
|
||||
posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c,
|
||||
posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c,
|
||||
posix/src/prwlockwrlock.c, posix/src/pspin.c,
|
||||
posix/src/pspindestroy.c, posix/src/pspininit.c,
|
||||
posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c,
|
||||
posix/src/pspintrylock.c, posix/src/pspinunlock.c,
|
||||
posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c,
|
||||
posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c: New files.
|
||||
|
||||
2006-11-14 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* configure.ac: Require inttypes.h, check for stdint.h.
|
||||
|
||||
@@ -1015,7 +1015,7 @@ fillBufferQueue (struct rtems_termios_tty *tty)
|
||||
{
|
||||
rtems_interval timeout = tty->rawInBufSemaphoreFirstTimeout;
|
||||
rtems_status_code sc;
|
||||
int wait = (int)1;
|
||||
int wait = (int)1;
|
||||
|
||||
while ( wait ) {
|
||||
/*
|
||||
|
||||
@@ -25,7 +25,8 @@ include_rtems_posix_HEADERS = include/rtems/posix/cancel.h \
|
||||
include/rtems/posix/priority.h include/rtems/posix/psignal.h \
|
||||
include/rtems/posix/pthread.h include/rtems/posix/semaphore.h \
|
||||
include/rtems/posix/threadsup.h include/rtems/posix/time.h \
|
||||
include/rtems/posix/timer.h
|
||||
include/rtems/posix/timer.h include/rtems/posix/barrier.h \
|
||||
include/rtems/posix/rwlock.h include/rtems/posix/spinlock.h
|
||||
|
||||
if HAS_MP
|
||||
include_rtems_posix_HEADERS += include/rtems/posix/condmp.h \
|
||||
@@ -37,7 +38,8 @@ include_rtems_posix_HEADERS += inline/rtems/posix/cond.inl \
|
||||
inline/rtems/posix/key.inl inline/rtems/posix/mqueue.inl \
|
||||
inline/rtems/posix/mutex.inl inline/rtems/posix/pthread.inl \
|
||||
inline/rtems/posix/priority.inl inline/rtems/posix/semaphore.inl \
|
||||
inline/rtems/posix/timer.inl
|
||||
inline/rtems/posix/timer.inl inline/rtems/posix/barrier.inl \
|
||||
inline/rtems/posix/rwlock.inl inline/rtems/posix/spinlock.inl
|
||||
|
||||
## src
|
||||
|
||||
@@ -50,6 +52,12 @@ libposix_a_SOURCES += src/execl.c src/execle.c src/execlp.c src/execv.c \
|
||||
src/execve.c src/execvp.c src/fork.c src/pthreadatfork.c src/wait.c \
|
||||
src/waitpid.c
|
||||
|
||||
## BARRIER_C_FILES
|
||||
libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \
|
||||
src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \
|
||||
src/pbarrierdestroy.c src/pbarrierinit.c \
|
||||
src/pbarriertranslatereturncode.c src/pbarrierwait.c
|
||||
|
||||
## CANCEL_C_FILES
|
||||
libposix_a_SOURCES += src/cancel.c src/cancelrun.c src/cleanuppop.c \
|
||||
src/cleanuppush.c src/setcancelstate.c src/setcanceltype.c \
|
||||
@@ -115,6 +123,14 @@ libposix_a_SOURCES += src/psignal.c src/alarm.c src/kill.c src/killinfo.c \
|
||||
src/sigprocmask.c src/sigqueue.c src/sigsuspend.c src/sigtimedwait.c \
|
||||
src/sigwait.c src/sigwaitinfo.c src/signal_2.c src/ualarm.c
|
||||
|
||||
## RWLOCK_C_FILES
|
||||
libposix_a_SOURCES += src/prwlock.c src/prwlockdestroy.c src/prwlockinit.c \
|
||||
src/prwlockrdlock.c src/prwlocktimedrdlock.c src/prwlocktimedwrlock.c \
|
||||
src/prwlocktryrdlock.c src/prwlocktrywrlock.c src/prwlockunlock.c \
|
||||
src/prwlockwrlock.c src/rwlockattrdestroy.c src/rwlockattrgetpshared.c \
|
||||
src/rwlockattrinit.c src/rwlockattrsetpshared.c \
|
||||
src/prwlocktranslatereturncode.c
|
||||
|
||||
## SEMAPHORE_C_FILES
|
||||
libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
|
||||
src/semaphoredeletesupp.c src/semaphoremp.c src/semaphorenametoid.c \
|
||||
@@ -122,6 +138,11 @@ libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
|
||||
src/semgetvalue.c src/seminit.c src/semopen.c src/sempost.c \
|
||||
src/semtimedwait.c src/semtrywait.c src/semunlink.c src/semwait.c
|
||||
|
||||
## SPINLOCK_C_FILES
|
||||
libposix_a_SOURCES += src/pspin.c src/pspindestroy.c src/pspininit.c \
|
||||
src/pspinlock.c src/pspinlocktranslatereturncode.c src/pspintrylock.c \
|
||||
src/pspinunlock.c
|
||||
|
||||
## TIME_C_FILES
|
||||
libposix_a_SOURCES += src/adjtime.c src/time.c src/posixtimespecsubtract.c \
|
||||
src/posixtimespectointerval.c src/posixintervaltotimespec.c \
|
||||
|
||||
90
cpukit/posix/include/rtems/posix/barrier.h
Normal file
90
cpukit/posix/include/rtems/posix/barrier.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file rtems/posix/barrier.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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-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_POSIX_BARRIER_H
|
||||
#define _RTEMS_POSIX_BARRIER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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 implement the barrier. */
|
||||
CORE_barrier_Control Barrier;
|
||||
} POSIX_Barrier_Control;
|
||||
|
||||
/**
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
POSIX_EXTERN Objects_Information _POSIX_Barrier_Information;
|
||||
|
||||
/**
|
||||
* @brief _POSIX_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 _POSIX_Barrier_Manager_initialization(
|
||||
uint32_t maximum_barriers
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Barrier_Translate_core_barrier_return_code (
|
||||
*
|
||||
* This routine translates SuperCore Barrier status codes into the
|
||||
* corresponding POSIX ones.
|
||||
*
|
||||
*
|
||||
* @param[in] the_barrier_status is the SuperCore status.
|
||||
*
|
||||
* @return the corresponding POSIX status
|
||||
*/
|
||||
int _POSIX_Barrier_Translate_core_barrier_return_code(
|
||||
CORE_barrier_Status the_barrier_status
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/posix/barrier.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -54,6 +54,9 @@ typedef struct {
|
||||
int maximum_queued_signals;
|
||||
int maximum_message_queues;
|
||||
int maximum_semaphores;
|
||||
int maximum_barriers;
|
||||
int maximum_rwlocks;
|
||||
int maximum_spinlocks;
|
||||
int number_of_initialization_threads;
|
||||
posix_initialization_threads_table *User_initialization_threads_table;
|
||||
} posix_api_configuration_table;
|
||||
|
||||
90
cpukit/posix/include/rtems/posix/rwlock.h
Normal file
90
cpukit/posix/include/rtems/posix/rwlock.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file rtems/posix/rwlock.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* This include file contains all the constants and structures associated
|
||||
* with the POSIX RWLock Manager.
|
||||
*
|
||||
* Directives provided are:
|
||||
*
|
||||
* + create a RWLock
|
||||
* + delete a RWLock
|
||||
* + wait for a RWLock
|
||||
*
|
||||
* 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_POSIX_RWLOCK_H
|
||||
#define _RTEMS_POSIX_RWLOCK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/corerwlock.h>
|
||||
|
||||
/**
|
||||
* This type defines the control block used to manage each RWLock.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
/** This is used to manage a RWLock as an object. */
|
||||
Objects_Control Object;
|
||||
/** This is used to implement the RWLock. */
|
||||
CORE_RWLock_Control RWLock;
|
||||
} POSIX_RWLock_Control;
|
||||
|
||||
/**
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
POSIX_EXTERN Objects_Information _POSIX_RWLock_Information;
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Manager_initialization
|
||||
*
|
||||
* This routine performs the initialization necessary for this manager.
|
||||
*
|
||||
* @param[in] maximum_rwlocks is the total number of RWLocks allowed to
|
||||
* concurrently be active in the system.
|
||||
*/
|
||||
|
||||
void _POSIX_RWLock_Manager_initialization(
|
||||
uint32_t maximum_rwlocks
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Translate_core_RWLock_return_code (
|
||||
*
|
||||
* This routine translates SuperCore RWLock status codes into the
|
||||
* corresponding POSIX ones.
|
||||
*
|
||||
*
|
||||
* @param[in] the_RWLock_status is the SuperCore status.
|
||||
*
|
||||
* @return the corresponding POSIX status
|
||||
*/
|
||||
int _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
CORE_RWLock_Status the_RWLock_status
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/posix/rwlock.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
90
cpukit/posix/include/rtems/posix/spinlock.h
Normal file
90
cpukit/posix/include/rtems/posix/spinlock.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file rtems/posix/spinlock.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* This include file contains all the constants and structures associated
|
||||
* with the POSIX Spinlock Manager.
|
||||
*
|
||||
* Directives provided are:
|
||||
*
|
||||
* + create a spinlock
|
||||
* + delete a spinlock
|
||||
* + wait for a spinlock
|
||||
*
|
||||
* 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_POSIX_SPINLOCK_H
|
||||
#define _RTEMS_POSIX_SPINLOCK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/corespinlock.h>
|
||||
|
||||
/**
|
||||
* This type defines the control block used to manage each spinlock.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
/** This is used to manage a spinlock as an object. */
|
||||
Objects_Control Object;
|
||||
/** This is used to implement the spinlock. */
|
||||
CORE_spinlock_Control Spinlock;
|
||||
} POSIX_Spinlock_Control;
|
||||
|
||||
/**
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
POSIX_EXTERN Objects_Information _POSIX_Spinlock_Information;
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Manager_initialization
|
||||
*
|
||||
* This routine performs the initialization necessary for this manager.
|
||||
*
|
||||
* @param[in] maximum_spinlocks is the total number of spinlocks allowed to
|
||||
* concurrently be active in the system.
|
||||
*/
|
||||
|
||||
void _POSIX_Spinlock_Manager_initialization(
|
||||
uint32_t maximum_spinlocks
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Translate_core_spinlock_return_code (
|
||||
*
|
||||
* This routine translates SuperCore Spinlock status codes into the
|
||||
* corresponding POSIX ones.
|
||||
*
|
||||
*
|
||||
* @param[in] the_spinlock_status is the SuperCore status.
|
||||
*
|
||||
* @return the corresponding POSIX status
|
||||
*/
|
||||
int _POSIX_Spinlock_Translate_core_spinlock_return_code(
|
||||
CORE_spinlock_Status the_spinlock_status
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/posix/spinlock.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -22,8 +22,7 @@
|
||||
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
|
||||
(4 * TOD_SECONDS_PER_DAY))
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* _POSIX_Timespec_subtract
|
||||
*/
|
||||
|
||||
@@ -41,8 +40,7 @@ Watchdog_Interval _POSIX_Timespec_to_interval(
|
||||
const struct timespec *time
|
||||
);
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* _POSIX_Interval_to_timespec
|
||||
*/
|
||||
|
||||
@@ -51,4 +49,12 @@ void _POSIX_Interval_to_timespec(
|
||||
struct timespec *time
|
||||
);
|
||||
|
||||
/*
|
||||
* _POSIX_Absolute_timeout_to_ticks
|
||||
*/
|
||||
int _POSIX_Absolute_timeout_to_ticks(
|
||||
const struct timespec *abstime,
|
||||
Watchdog_Interval *ticks_out
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
85
cpukit/posix/inline/rtems/posix/barrier.inl
Normal file
85
cpukit/posix/inline/rtems/posix/barrier.inl
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @file rtems/posix/barrier.inl
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the static inlin implementation of the inlined
|
||||
* routines from the POSIX 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_POSIX_BARRIER_INL
|
||||
#define _RTEMS_POSIX_BARRIER_INL
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Barrier_Allocate
|
||||
*
|
||||
* 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 )
|
||||
{
|
||||
return (POSIX_Barrier_Control *)
|
||||
_Objects_Allocate( &_POSIX_Barrier_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Barrier_Free
|
||||
*
|
||||
* 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
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_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 POSIX_Barrier_Control *_POSIX_Barrier_Get (
|
||||
pthread_barrier_t *barrier,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Barrier_Control *) _Objects_Get(
|
||||
&_POSIX_Barrier_Information,
|
||||
*((Objects_Id *)barrier),
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Barrier_Is_null
|
||||
*
|
||||
* This function returns TRUE if the_barrier is NULL and FALSE otherwise.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Barrier_Is_null (
|
||||
POSIX_Barrier_Control *the_barrier
|
||||
)
|
||||
{
|
||||
return ( the_barrier == NULL );
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
85
cpukit/posix/inline/rtems/posix/rwlock.inl
Normal file
85
cpukit/posix/inline/rtems/posix/rwlock.inl
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @file rtems/posix/RWLock.inl
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the static inlin implementation of the inlined
|
||||
* routines from the POSIX RWLock 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_POSIX_RWLOCK_INL
|
||||
#define _RTEMS_POSIX_RWLOCK_INL
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Allocate
|
||||
*
|
||||
* This function allocates a RWLock control block from
|
||||
* the inactive chain of free RWLock control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Allocate( void )
|
||||
{
|
||||
return (POSIX_RWLock_Control *)
|
||||
_Objects_Allocate( &_POSIX_RWLock_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Free
|
||||
*
|
||||
* This routine frees a RWLock control block to the
|
||||
* inactive chain of free RWLock control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _POSIX_RWLock_Free (
|
||||
POSIX_RWLock_Control *the_RWLock
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_RWLock_Information, &the_RWLock->Object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Get
|
||||
*
|
||||
* This function maps RWLock IDs to RWLock control blocks.
|
||||
* If ID corresponds to a local RWLock, then it returns
|
||||
* the_RWLock control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. if the RWLock ID is global and
|
||||
* resides on a remote node, then location is set to OBJECTS_REMOTE,
|
||||
* and the_RWLock is undefined. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the_RWLock is undefined.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get (
|
||||
pthread_rwlock_t *RWLock,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_RWLock_Control *) _Objects_Get(
|
||||
&_POSIX_RWLock_Information,
|
||||
*((Objects_Id *)RWLock),
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Is_null
|
||||
*
|
||||
* This function returns TRUE if the_RWLock is NULL and FALSE otherwise.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE boolean _POSIX_RWLock_Is_null (
|
||||
POSIX_RWLock_Control *the_RWLock
|
||||
)
|
||||
{
|
||||
return ( the_RWLock == NULL );
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
85
cpukit/posix/inline/rtems/posix/spinlock.inl
Normal file
85
cpukit/posix/inline/rtems/posix/spinlock.inl
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @file rtems/posix/spinlock.inl
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the static inlin implementation of the inlined
|
||||
* routines from the POSIX Spinlock 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_POSIX_SPINLOCK_INL
|
||||
#define _RTEMS_POSIX_SPINLOCK_INL
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Allocate
|
||||
*
|
||||
* This function allocates a spinlock control block from
|
||||
* the inactive chain of free spinlock control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void )
|
||||
{
|
||||
return (POSIX_Spinlock_Control *)
|
||||
_Objects_Allocate( &_POSIX_Spinlock_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Free
|
||||
*
|
||||
* This routine frees a spinlock control block to the
|
||||
* inactive chain of free spinlock control blocks.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free (
|
||||
POSIX_Spinlock_Control *the_spinlock
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Get
|
||||
*
|
||||
* This function maps spinlock IDs to spinlock control blocks.
|
||||
* If ID corresponds to a local spinlock, then it returns
|
||||
* the_spinlock control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. if the spinlock ID is global and
|
||||
* resides on a remote node, then location is set to OBJECTS_REMOTE,
|
||||
* and the_spinlock is undefined. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the_spinlock is undefined.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get (
|
||||
pthread_spinlock_t *spinlock,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Spinlock_Control *) _Objects_Get(
|
||||
&_POSIX_Spinlock_Information,
|
||||
*((Objects_Id *)spinlock),
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Is_null
|
||||
*
|
||||
* This function returns TRUE if the_spinlock is NULL and FALSE otherwise.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Spinlock_Is_null (
|
||||
POSIX_Spinlock_Control *the_spinlock
|
||||
)
|
||||
{
|
||||
return ( the_spinlock == NULL );
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -44,6 +44,10 @@ $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp):
|
||||
@: > $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
|
||||
$(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/cancel.h: include/rtems/posix/cancel.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/cancel.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/cancel.h
|
||||
@@ -84,10 +88,18 @@ $(PROJECT_INCLUDE)/rtems/posix/pthread.h: include/rtems/posix/pthread.h $(PROJEC
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthread.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthread.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
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/semaphore.h: include/rtems/posix/semaphore.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/spinlock.h: include/rtems/posix/spinlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.h
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/threadsup.h: include/rtems/posix/threadsup.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/threadsup.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/threadsup.h
|
||||
@@ -121,6 +133,11 @@ $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h: include/rtems/posix/semaphoremp.h
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h
|
||||
endif
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/barrier.inl: inline/rtems/posix/barrier.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/cond.inl: inline/rtems/posix/cond.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/cond.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/cond.inl
|
||||
@@ -145,10 +162,18 @@ $(PROJECT_INCLUDE)/rtems/posix/priority.inl: inline/rtems/posix/priority.inl $(P
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priority.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priority.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/rwlock.inl: inline/rtems/posix/rwlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/semaphore.inl: inline/rtems/posix/semaphore.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/spinlock.inl: inline/rtems/posix/spinlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/posix/timer.inl: inline/rtems/posix/timer.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.inl
|
||||
|
||||
34
cpukit/posix/src/barrierattrdestroy.c
Normal file
34
cpukit/posix/src/barrierattrdestroy.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/states.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
#include <rtems/posix/cond.h>
|
||||
#include <rtems/posix/time.h>
|
||||
#include <rtems/posix/mutex.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* Barrier Initialization Attributes
|
||||
*/
|
||||
|
||||
int pthread_barrierattr_destroy(
|
||||
pthread_barrierattr_t *attr
|
||||
)
|
||||
{
|
||||
if ( !attr || attr->is_initialized == FALSE )
|
||||
return EINVAL;
|
||||
|
||||
attr->is_initialized = FALSE;
|
||||
return 0;
|
||||
}
|
||||
30
cpukit/posix/src/barrierattrgetpshared.c
Normal file
30
cpukit/posix/src/barrierattrgetpshared.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* Barrier Attributes Get Process Shared
|
||||
*/
|
||||
|
||||
int pthread_barrierattr_getpshared(
|
||||
const pthread_barrierattr_t *attr,
|
||||
int *pshared
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
*pshared = attr->process_shared;
|
||||
return 0;
|
||||
}
|
||||
29
cpukit/posix/src/barrierattrinit.c
Normal file
29
cpukit/posix/src/barrierattrinit.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* Barrier Attributes Initialization
|
||||
*/
|
||||
|
||||
int pthread_barrierattr_init(
|
||||
pthread_barrierattr_t *attr
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
attr->is_initialized = TRUE;
|
||||
attr->process_shared = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
}
|
||||
37
cpukit/posix/src/barrierattrsetpshared.c
Normal file
37
cpukit/posix/src/barrierattrsetpshared.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* Barrier Attributes Set Process Shared
|
||||
*/
|
||||
|
||||
int pthread_barrierattr_setpshared(
|
||||
pthread_barrierattr_t *attr,
|
||||
int pshared
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
switch ( pshared ) {
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
case PTHREAD_PROCESS_PRIVATE:
|
||||
attr->process_shared = pshared;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
60
cpukit/posix/src/pbarrier.c
Normal file
60
cpukit/posix/src/pbarrier.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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/posix/barrier.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Barrier_Manager_initialization
|
||||
*
|
||||
* Input parameters:
|
||||
* maximum_barriers - maximum configured barriers
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
void _POSIX_Barrier_Manager_initialization(
|
||||
uint32_t maximum_barriers
|
||||
)
|
||||
{
|
||||
_Objects_Initialize_information(
|
||||
&_POSIX_Barrier_Information, /* object information table */
|
||||
OBJECTS_POSIX_API, /* object API */
|
||||
OBJECTS_POSIX_BARRIERS, /* object class */
|
||||
maximum_barriers, /* maximum objects of this class */
|
||||
sizeof( POSIX_Barrier_Control ),/* size of this object's control block */
|
||||
FALSE, /* TRUE if the name is a string */
|
||||
0 /* 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
|
||||
);
|
||||
}
|
||||
71
cpukit/posix/src/pbarrierdestroy.c
Normal file
71
cpukit/posix/src/pbarrierdestroy.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* POSIX Barrier Manager -- Destroy 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/barrier.h>
|
||||
|
||||
/*
|
||||
* pthread_barrier_destroy
|
||||
*
|
||||
* 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:
|
||||
* barrier - barrier id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_barrier_destroy(
|
||||
pthread_barrier_t *barrier
|
||||
)
|
||||
{
|
||||
POSIX_Barrier_Control *the_barrier = NULL;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !barrier )
|
||||
return EINVAL;
|
||||
|
||||
the_barrier = _POSIX_Barrier_Get( barrier, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
_Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
|
||||
|
||||
_POSIX_Barrier_Free( the_barrier );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
94
cpukit/posix/src/pbarrierinit.c
Normal file
94
cpukit/posix/src/pbarrierinit.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* POSIX Barrier Manager -- Initialize 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/barrier.h>
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
int pthread_barrier_init(
|
||||
pthread_barrier_t *barrier,
|
||||
const pthread_barrierattr_t *attr,
|
||||
unsigned int count
|
||||
)
|
||||
{
|
||||
POSIX_Barrier_Control *the_barrier;
|
||||
CORE_barrier_Attributes the_attributes;
|
||||
|
||||
|
||||
if ( !barrier )
|
||||
return EINVAL;
|
||||
|
||||
if ( count == 0 )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
switch ( attr->process_shared ) {
|
||||
case PTHREAD_PROCESS_PRIVATE: /* only supported values */
|
||||
break;
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
|
||||
the_attributes.maximum_count = count;
|
||||
|
||||
_Thread_Disable_dispatch(); /* prevents deletion */
|
||||
|
||||
the_barrier = _POSIX_Barrier_Allocate();
|
||||
|
||||
if ( !the_barrier ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
_CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
|
||||
|
||||
_Objects_Open(
|
||||
&_POSIX_Barrier_Information,
|
||||
&the_barrier->Object,
|
||||
0
|
||||
);
|
||||
|
||||
*barrier = the_barrier->Object.id;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
51
cpukit/posix/src/pbarriertranslatereturncode.c
Normal file
51
cpukit/posix/src/pbarriertranslatereturncode.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/barrier.h>
|
||||
|
||||
/*
|
||||
* _POSIX_Barrier_Translate_core_barrier_return_code
|
||||
*
|
||||
* Input parameters:
|
||||
* the_barrier_status - barrier status code to translate
|
||||
*
|
||||
* Output parameters:
|
||||
* status code - translated POSIX status code
|
||||
*
|
||||
*/
|
||||
|
||||
static int _POSIX_Barrier_Return_codes[] = {
|
||||
0, /* CORE_BARRIER_STATUS_SUCCESSFUL */
|
||||
PTHREAD_BARRIER_SERIAL_THREAD,
|
||||
/* CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED */
|
||||
-1, /* CORE_BARRIER_WAS_DELETED */
|
||||
0 /* CORE_BARRIER_TIMEOUT */
|
||||
};
|
||||
|
||||
|
||||
int _POSIX_Barrier_Translate_core_barrier_return_code(
|
||||
CORE_barrier_Status the_barrier_status
|
||||
)
|
||||
{
|
||||
if ( the_barrier_status <= CORE_BARRIER_TIMEOUT )
|
||||
return _POSIX_Barrier_Return_codes[the_barrier_status];
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
68
cpukit/posix/src/pbarrierwait.c
Normal file
68
cpukit/posix/src/pbarrierwait.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* POSIX 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/barrier.h>
|
||||
|
||||
/*
|
||||
* pthread_barrier_wait
|
||||
*
|
||||
* This directive allows a thread to wait at a barrier.
|
||||
*
|
||||
* Input parameters:
|
||||
* barrier - barrier id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* PTHREAD_BARRIER_SERIAL_THREAD - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_barrier_wait(
|
||||
pthread_barrier_t *barrier
|
||||
)
|
||||
{
|
||||
POSIX_Barrier_Control *the_barrier = NULL;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !barrier )
|
||||
return EINVAL;
|
||||
|
||||
the_barrier = _POSIX_Barrier_Get( barrier, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_barrier_Wait(
|
||||
&the_barrier->Barrier,
|
||||
the_barrier->Object.id,
|
||||
TRUE,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_Barrier_Translate_core_barrier_return_code(
|
||||
_Thread_Executing->Wait.return_code );
|
||||
|
||||
}
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
48
cpukit/posix/src/prwlock.c
Normal file
48
cpukit/posix/src/prwlock.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* RWLock Manager -- Initialization
|
||||
*
|
||||
* 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/posix/rwlock.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_RWLock_Manager_initialization
|
||||
*
|
||||
* Input parameters:
|
||||
* maximum_rwlocks - maximum configured rwlocks
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
void _POSIX_RWLock_Manager_initialization(
|
||||
uint32_t maximum_rwlocks
|
||||
)
|
||||
{
|
||||
_Objects_Initialize_information(
|
||||
&_POSIX_RWLock_Information, /* object information table */
|
||||
OBJECTS_POSIX_API, /* object API */
|
||||
OBJECTS_POSIX_SPINLOCKS, /* object class */
|
||||
maximum_rwlocks, /* maximum objects of this class */
|
||||
sizeof( POSIX_RWLock_Control ), /* size of this object's control block */
|
||||
FALSE, /* TRUE if the name is a string */
|
||||
0 /* 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
|
||||
);
|
||||
}
|
||||
73
cpukit/posix/src/prwlockdestroy.c
Normal file
73
cpukit/posix/src/prwlockdestroy.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Destroy a RWLock
|
||||
*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_destroy
|
||||
*
|
||||
* This directive allows a thread to delete a rwlock specified by
|
||||
* the rwlock id. The rwlock is freed back to the inactive
|
||||
* rwlock chain.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_destroy(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock = NULL;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
#if 0
|
||||
if ( the_rwlock->RWLock.number_of_waiting_threads != 0 ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EBUSY;
|
||||
}
|
||||
#endif
|
||||
|
||||
_Objects_Close( &_POSIX_RWLock_Information, &the_rwlock->Object );
|
||||
|
||||
_POSIX_RWLock_Free( the_rwlock );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
90
cpukit/posix/src/prwlockinit.c
Normal file
90
cpukit/posix/src/prwlockinit.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Destroy a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_init
|
||||
*
|
||||
* This directive creates a rwlock. A rwlock id is returned.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
* attr - rwlock attributes
|
||||
*
|
||||
* Output parameters:
|
||||
* rwlock - rwlock id
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_init(
|
||||
pthread_rwlock_t *rwlock,
|
||||
const pthread_rwlockattr_t *attr
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
CORE_RWLock_Attributes the_attributes;
|
||||
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
switch ( attr->process_shared ) {
|
||||
case PTHREAD_PROCESS_PRIVATE: /* only supported values */
|
||||
break;
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
the_attributes.discipline = CORE_RWLOCK_AUTOMATIC_RELEASE;
|
||||
*/
|
||||
|
||||
_Thread_Disable_dispatch(); /* prevents deletion */
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Allocate();
|
||||
|
||||
if ( !the_rwlock ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
_CORE_RWLock_Initialize( &the_rwlock->RWLock, &the_attributes );
|
||||
|
||||
_Objects_Open(
|
||||
&_POSIX_RWLock_Information,
|
||||
&the_rwlock->Object,
|
||||
0
|
||||
);
|
||||
|
||||
*rwlock = the_rwlock->Object.id;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
71
cpukit/posix/src/prwlockrdlock.c
Normal file
71
cpukit/posix/src/prwlockrdlock.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Obtain a Read Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_rdlock
|
||||
*
|
||||
* This directive attempts to obtain a read only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_rdlock(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_reading(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
TRUE, // we are willing to wait forever
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
79
cpukit/posix/src/prwlocktimedrdlock.c
Normal file
79
cpukit/posix/src/prwlocktimedrdlock.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Attempt to Obtain a Read Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_timedrdlock
|
||||
*
|
||||
* This directive attempts to obtain a read only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_timedrdlock(
|
||||
pthread_rwlock_t *rwlock,
|
||||
const struct timespec *abstime
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
Watchdog_Interval ticks;
|
||||
int status;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
||||
if ( !status )
|
||||
return status;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_reading(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
TRUE, // we are willing to wait up to ticks
|
||||
ticks,
|
||||
NULL
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
79
cpukit/posix/src/prwlocktimedwrlock.c
Normal file
79
cpukit/posix/src/prwlocktimedwrlock.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_timedwrlock
|
||||
*
|
||||
* This directive attempts to obtain a write only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_timedwrlock(
|
||||
pthread_rwlock_t *rwlock,
|
||||
const struct timespec *abstime
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
int status;
|
||||
Watchdog_Interval ticks;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
||||
if ( !status )
|
||||
return status;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_writing(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
TRUE, // we are willing to wait up to ticks
|
||||
ticks,
|
||||
NULL
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
51
cpukit/posix/src/prwlocktranslatereturncode.c
Normal file
51
cpukit/posix/src/prwlocktranslatereturncode.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* _POSIX_RWLock_Translate_core_rwlock_return_code
|
||||
*
|
||||
* Input parameters:
|
||||
* the_rwlock_status - rwlock status code to translate
|
||||
*
|
||||
* Output parameters:
|
||||
* status code - translated POSIX status code
|
||||
*
|
||||
*/
|
||||
|
||||
/* XXX fix me */
|
||||
static int _POSIX_RWLock_Return_codes[] = {
|
||||
0, /* CORE_RWLOCK_SUCCESSFUL */
|
||||
EINVAL, /* CORE_RWLOCK_DELETED */
|
||||
EBUSY, /* CORE_RWLOCK_UNAVAILABLE */
|
||||
ETIMEDOUT, /* CORE_RWLOCK_TIMEOUT */
|
||||
};
|
||||
|
||||
|
||||
int _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
CORE_RWLock_Status the_rwlock_status
|
||||
)
|
||||
{
|
||||
if ( the_rwlock_status <= CORE_RWLOCK_STATUS_LAST )
|
||||
return _POSIX_RWLock_Return_codes[the_rwlock_status];
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
72
cpukit/posix/src/prwlocktryrdlock.c
Normal file
72
cpukit/posix/src/prwlocktryrdlock.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Attempt to Obtain a Read Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_tryrdlock
|
||||
*
|
||||
* This directive attempts to obtain a read only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_tryrdlock(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_reading(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
FALSE, // do not wait for the rwlock
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
71
cpukit/posix/src/prwlocktrywrlock.c
Normal file
71
cpukit/posix/src/prwlocktrywrlock.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_trywrlock
|
||||
*
|
||||
* This directive attempts to obtain a Write only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_trywrlock(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_writing(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
FALSE, // we are not willing to wait
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
63
cpukit/posix/src/prwlockunlock.c
Normal file
63
cpukit/posix/src/prwlockunlock.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Release a lock held on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_unlock
|
||||
*
|
||||
* This directive attempts to release a lock on an RWLock.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_unlock(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
/* XXX */
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
71
cpukit/posix/src/prwlockwrlock.c
Normal file
71
cpukit/posix/src/prwlockwrlock.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* POSIX RWLock Manager -- Obtain a Write Lock on a RWLock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/rwlock.h>
|
||||
|
||||
/*
|
||||
* pthread_rwlock_wrlock
|
||||
*
|
||||
* This directive attempts to obtain a write only lock on an rwlock instance.
|
||||
*
|
||||
* Input parameters:
|
||||
* rwlock - pointer to rwlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_rwlock_wrlock(
|
||||
pthread_rwlock_t *rwlock
|
||||
)
|
||||
{
|
||||
POSIX_RWLock_Control *the_rwlock;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !rwlock )
|
||||
return EINVAL;
|
||||
|
||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
|
||||
_CORE_RWLock_Obtain_for_writing(
|
||||
&the_rwlock->RWLock,
|
||||
*rwlock,
|
||||
FALSE, /* do not timeout -- wait forever */
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_RWLock_Translate_core_RWLock_return_code(
|
||||
(CORE_RWLock_Status) _Thread_Executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
60
cpukit/posix/src/pspin.c
Normal file
60
cpukit/posix/src/pspin.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Spinlock Manager
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This package is the implementation of the Spinlock Manager.
|
||||
*
|
||||
* Directives provided are:
|
||||
*
|
||||
* + create a spinlock
|
||||
* + get an ID of a spinlock
|
||||
* + delete a spinlock
|
||||
* + acquire a spinlock
|
||||
* + release a spinlock
|
||||
*
|
||||
* 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/posix/spinlock.h>
|
||||
|
||||
/**
|
||||
* @brief _POSIX_Spinlock_Manager_initialization
|
||||
*
|
||||
* Input parameters:
|
||||
* maximum_spinlocks - maximum configured spinlocks
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
void _POSIX_Spinlock_Manager_initialization(
|
||||
uint32_t maximum_spinlocks
|
||||
)
|
||||
{
|
||||
_Objects_Initialize_information(
|
||||
&_POSIX_Spinlock_Information, /* object information table */
|
||||
OBJECTS_POSIX_API, /* object API */
|
||||
OBJECTS_POSIX_SPINLOCKS, /* object class */
|
||||
maximum_spinlocks, /* maximum objects of this class */
|
||||
sizeof( POSIX_Spinlock_Control ),/* size of this object's control block */
|
||||
FALSE, /* TRUE if the name is a string */
|
||||
0 /* 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
|
||||
);
|
||||
}
|
||||
71
cpukit/posix/src/pspindestroy.c
Normal file
71
cpukit/posix/src/pspindestroy.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* POSIX Spinlock Manager -- Destroy a Spinlock
|
||||
*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* pthread_spin_destroy
|
||||
*
|
||||
* This directive allows a thread to delete a spinlock specified by
|
||||
* the spinlock id. The spinlock is freed back to the inactive
|
||||
* spinlock chain.
|
||||
*
|
||||
* Input parameters:
|
||||
* spinlock - spinlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_spin_destroy(
|
||||
pthread_spinlock_t *spinlock
|
||||
)
|
||||
{
|
||||
POSIX_Spinlock_Control *the_spinlock = NULL;
|
||||
Objects_Locations location;
|
||||
|
||||
if ( !spinlock )
|
||||
return EINVAL;
|
||||
|
||||
the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
_Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object );
|
||||
|
||||
_POSIX_Spinlock_Free( the_spinlock );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
80
cpukit/posix/src/pspininit.c
Normal file
80
cpukit/posix/src/pspininit.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* POSIX Spinlock Manager -- Initialize a Spinlock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* pthread_spinlock_init
|
||||
*
|
||||
* This directive creates a spinlock. A spinlock id is returned.
|
||||
*
|
||||
* Input parameters:
|
||||
* spinlock - pointer to spinlock id
|
||||
* pshared - is this spinlock shared between processes
|
||||
*
|
||||
* Output parameters:
|
||||
* spinlock - spinlock id
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_spin_init(
|
||||
pthread_spinlock_t *spinlock,
|
||||
int pshared
|
||||
)
|
||||
{
|
||||
POSIX_Spinlock_Control *the_spinlock;
|
||||
CORE_spinlock_Attributes attributes;
|
||||
|
||||
|
||||
if ( !spinlock )
|
||||
return EINVAL;
|
||||
|
||||
switch ( pshared ) {
|
||||
case PTHREAD_PROCESS_PRIVATE: /* only supported values */
|
||||
break;
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
_Thread_Disable_dispatch(); /* prevents deletion */
|
||||
|
||||
the_spinlock = _POSIX_Spinlock_Allocate();
|
||||
|
||||
if ( !the_spinlock ) {
|
||||
_Thread_Enable_dispatch();
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
_CORE_spinlock_Initialize( &the_spinlock->Spinlock, &attributes );
|
||||
|
||||
_Objects_Open(
|
||||
&_POSIX_Spinlock_Information,
|
||||
&the_spinlock->Object,
|
||||
0
|
||||
);
|
||||
|
||||
*spinlock = the_spinlock->Object.id;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
return 0;
|
||||
}
|
||||
60
cpukit/posix/src/pspinlock.c
Normal file
60
cpukit/posix/src/pspinlock.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* POSIX Spinlock Manager -- Wait at a Spinlock
|
||||
*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* pthread_spin_lock
|
||||
*
|
||||
* This directive allows a thread to wait at a spinlock.
|
||||
*
|
||||
* Input parameters:
|
||||
* spinlock - spinlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_spin_lock(
|
||||
pthread_spinlock_t *spinlock
|
||||
)
|
||||
{
|
||||
POSIX_Spinlock_Control *the_spinlock = NULL;
|
||||
Objects_Locations location;
|
||||
CORE_spinlock_Status status;
|
||||
|
||||
if ( !spinlock )
|
||||
return EINVAL;
|
||||
|
||||
the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, TRUE, 0 );
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
|
||||
}
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
53
cpukit/posix/src/pspinlocktranslatereturncode.c
Normal file
53
cpukit/posix/src/pspinlocktranslatereturncode.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Spinlock 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* _POSIX_Spinlock_Translate_core_spinlock_return_code
|
||||
*
|
||||
* Input parameters:
|
||||
* the_spinlock_status - spinlock status code to translate
|
||||
*
|
||||
* Output parameters:
|
||||
* status code - translated POSIX status code
|
||||
*
|
||||
*/
|
||||
|
||||
/* XXX fix me */
|
||||
static int _POSIX_Spinlock_Return_codes[] = {
|
||||
0, /* CORE_SPINLOCK_SUCCESSFUL */
|
||||
EDEADLK, /* CORE_SPINLOCK_HOLDER_RELOCKING */
|
||||
-1, /* CORE_SPINLOCK_TIMEOUT */
|
||||
EBUSY, /* CORE_SPINLOCK_IS_BUSY */
|
||||
EBUSY, /* CORE_SPINLOCK_UNAVAILABLE */
|
||||
0 /* CORE_SPINLOCK_NOT_LOCKED */
|
||||
};
|
||||
|
||||
|
||||
int _POSIX_Spinlock_Translate_core_spinlock_return_code(
|
||||
CORE_spinlock_Status the_spinlock_status
|
||||
)
|
||||
{
|
||||
if ( the_spinlock_status <= CORE_SPINLOCK_STATUS_LAST )
|
||||
return _POSIX_Spinlock_Return_codes[the_spinlock_status];
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
60
cpukit/posix/src/pspintrylock.c
Normal file
60
cpukit/posix/src/pspintrylock.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* POSIX Spinlock Manager -- Wait at a Spinlock
|
||||
*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* pthread_spin_trylock
|
||||
*
|
||||
* This directive allows a thread to poll an attempt at locking a spinlock.
|
||||
*
|
||||
* Input parameters:
|
||||
* spinlock - spinlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_spin_trylock(
|
||||
pthread_spinlock_t *spinlock
|
||||
)
|
||||
{
|
||||
POSIX_Spinlock_Control *the_spinlock = NULL;
|
||||
Objects_Locations location;
|
||||
CORE_spinlock_Status status;
|
||||
|
||||
if ( !spinlock )
|
||||
return EINVAL;
|
||||
|
||||
the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, FALSE, 0 );
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
|
||||
}
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
60
cpukit/posix/src/pspinunlock.c
Normal file
60
cpukit/posix/src/pspinunlock.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* POSIX Spinlock Manager -- Wait at a Spinlock
|
||||
*
|
||||
* 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 <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/posix/spinlock.h>
|
||||
|
||||
/*
|
||||
* pthread_spin_unlock
|
||||
*
|
||||
* This directive allows a thread to wait at a spinlock.
|
||||
*
|
||||
* Input parameters:
|
||||
* spinlock - spinlock id
|
||||
*
|
||||
* Output parameters:
|
||||
* 0 - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
int pthread_spin_unlock(
|
||||
pthread_spinlock_t *spinlock
|
||||
)
|
||||
{
|
||||
POSIX_Spinlock_Control *the_spinlock = NULL;
|
||||
Objects_Locations location;
|
||||
CORE_spinlock_Status status;
|
||||
|
||||
if ( !spinlock )
|
||||
return EINVAL;
|
||||
|
||||
the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_REMOTE:
|
||||
case OBJECTS_ERROR:
|
||||
return EINVAL;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
status = _CORE_spinlock_Release( &the_spinlock->Spinlock );
|
||||
_Thread_Enable_dispatch();
|
||||
return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
|
||||
}
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
34
cpukit/posix/src/rwlockattrdestroy.c
Normal file
34
cpukit/posix/src/rwlockattrdestroy.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/states.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
#include <rtems/posix/cond.h>
|
||||
#include <rtems/posix/time.h>
|
||||
#include <rtems/posix/mutex.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* RWLock Initialization Attributes
|
||||
*/
|
||||
|
||||
int pthread_rwlockattr_destroy(
|
||||
pthread_rwlockattr_t *attr
|
||||
)
|
||||
{
|
||||
if ( !attr || attr->is_initialized == FALSE )
|
||||
return EINVAL;
|
||||
|
||||
attr->is_initialized = FALSE;
|
||||
return 0;
|
||||
}
|
||||
30
cpukit/posix/src/rwlockattrgetpshared.c
Normal file
30
cpukit/posix/src/rwlockattrgetpshared.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* RWLock Attributes Get Process Shared
|
||||
*/
|
||||
|
||||
int pthread_rwlockattr_getpshared(
|
||||
const pthread_rwlockattr_t *attr,
|
||||
int *pshared
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
*pshared = attr->process_shared;
|
||||
return 0;
|
||||
}
|
||||
29
cpukit/posix/src/rwlockattrinit.c
Normal file
29
cpukit/posix/src/rwlockattrinit.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* RWLock Attributes Initialization
|
||||
*/
|
||||
|
||||
int pthread_rwlockattr_init(
|
||||
pthread_rwlockattr_t *attr
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
attr->is_initialized = TRUE;
|
||||
attr->process_shared = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
}
|
||||
37
cpukit/posix/src/rwlockattrsetpshared.c
Normal file
37
cpukit/posix/src/rwlockattrsetpshared.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* RWLock Attributes Set Process Shared
|
||||
*/
|
||||
|
||||
int pthread_rwlockattr_setpshared(
|
||||
pthread_rwlockattr_t *attr,
|
||||
int pshared
|
||||
)
|
||||
{
|
||||
if ( !attr )
|
||||
return EINVAL;
|
||||
|
||||
if ( !attr->is_initialized )
|
||||
return EINVAL;
|
||||
|
||||
switch ( pshared ) {
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
case PTHREAD_PROCESS_PRIVATE:
|
||||
attr->process_shared = pshared;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <mqueue.h>
|
||||
#include <rtems/config.h>
|
||||
#include <rtems/score/object.h>
|
||||
/* #include <rtems/posix/barrier.h> */
|
||||
#include <rtems/posix/barrier.h>
|
||||
#include <rtems/posix/cond.h>
|
||||
#include <rtems/posix/config.h>
|
||||
#include <rtems/posix/key.h>
|
||||
@@ -42,10 +42,10 @@
|
||||
#include <rtems/posix/priority.h>
|
||||
#include <rtems/posix/psignal.h>
|
||||
#include <rtems/posix/pthread.h>
|
||||
/* #include <rtems/posix/rwlock.h> */
|
||||
#include <rtems/posix/rwlock.h>
|
||||
#include <rtems/posix/timer.h>
|
||||
#include <rtems/posix/semaphore.h>
|
||||
/* #include <rtems/posix/spinlock.h> */
|
||||
#include <rtems/posix/spinlock.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
/*PAGE
|
||||
@@ -65,11 +65,9 @@ posix_api_configuration_table _POSIX_Default_configuration = {
|
||||
0, /* number_of_initialization_threads */
|
||||
0, /* maximum_message_queues */
|
||||
0, /* maximum_semaphores */
|
||||
#if 0
|
||||
0, /* maximum_barriers */
|
||||
0, /* maximum_spinlocks */
|
||||
0, /* maximum_rwlocks */
|
||||
#endif
|
||||
NULL /* User_initialization_threads_table */
|
||||
};
|
||||
|
||||
@@ -122,14 +120,11 @@ void _POSIX_API_Initialize(
|
||||
|
||||
_POSIX_Timer_Manager_initialization( api_configuration->maximum_timers );
|
||||
|
||||
/* temporary while working */
|
||||
#if 0
|
||||
_POSIX_Barrier_Manager_initialization( api_configuration->maximum_barriers );
|
||||
|
||||
_POSIX_RWLock_Manager_initialization( api_configuration->maximum_rwlocks );
|
||||
|
||||
_POSIX_Spinlock_Manager_initialization(api_configuration->maximum_spinlocks);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,9 @@ include_rtems_score_HEADERS += inline/rtems/score/address.inl \
|
||||
inline/rtems/score/object.inl inline/rtems/score/priority.inl \
|
||||
inline/rtems/score/stack.inl inline/rtems/score/states.inl \
|
||||
inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
|
||||
inline/rtems/score/tod.inl inline/rtems/score/tqdata.inl \
|
||||
inline/rtems/score/userext.inl inline/rtems/score/watchdog.inl \
|
||||
inline/rtems/score/wkspace.inl
|
||||
inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
|
||||
inline/rtems/score/tqdata.inl inline/rtems/score/userext.inl \
|
||||
inline/rtems/score/watchdog.inl inline/rtems/score/wkspace.inl
|
||||
|
||||
if HAS_MP
|
||||
## We only build multiprocessing related files if HAS_MP was defined
|
||||
@@ -91,7 +91,7 @@ libscore_a_SOURCES += src/coremutex.c src/coremutexflush.c \
|
||||
|
||||
## CORE_RWLOCK_C_FILES
|
||||
libscore_a_SOURCES += src/corerwlock.c src/corerwlockobtainread.c \
|
||||
src/corerwlockobtainwrite.c src/corerwlockrelease.c
|
||||
src/corerwlockobtainwrite.c src/corerwlockrelease.c src/corerwlocktimeout.c
|
||||
|
||||
## CORE_SEMAPHORE_C_FILES
|
||||
libscore_a_SOURCES += src/coresem.c src/coresemflush.c src/coresemseize.c \
|
||||
|
||||
@@ -205,6 +205,22 @@ CORE_RWLock_Status _CORE_RWLock_Release(
|
||||
(_status) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief RWLock Specific Thread Queue Timeout
|
||||
*
|
||||
* This routine processes a thread which timeouts while waiting on
|
||||
* an RWLock's thread queue. It is called by the watchdog handler.
|
||||
*
|
||||
* @param[in] id is the Id of thread to timeout
|
||||
* @param[in] ignored is an unused pointer to a caller defined area
|
||||
*/
|
||||
|
||||
void _CORE_RWLock_Timeout(
|
||||
Objects_Id id,
|
||||
void *ignored
|
||||
);
|
||||
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/score/corerwlock.inl>
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,17 @@ extern "C" {
|
||||
* is extracted from a local thread queue.
|
||||
*/
|
||||
typedef void ( *Thread_queue_Flush_callout )(
|
||||
Thread_Control *
|
||||
Thread_Control *
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* The following type defines the callout used for timeout processing
|
||||
* methods.
|
||||
*/
|
||||
typedef void ( *Thread_queue_Timeout_callout )(
|
||||
Objects_Id,
|
||||
void *
|
||||
);
|
||||
|
||||
/** @brief Thread queue Dequeue
|
||||
@@ -61,14 +71,27 @@ Thread_Control *_Thread_queue_Dequeue(
|
||||
Thread_queue_Control *the_thread_queue
|
||||
);
|
||||
|
||||
/** @brief Thread queue Enqueue Wrapper
|
||||
*
|
||||
* This routine enqueues the currently executing thread on
|
||||
* the_thread_queue with an optional timeout.
|
||||
*/
|
||||
#define _Thread_queue_Enqueue( _the_thread_queue, _timeout ) \
|
||||
_Thread_queue_Enqueue_with_handler( \
|
||||
_the_thread_queue, \
|
||||
_timeout, \
|
||||
_Thread_queue_Timeout )
|
||||
|
||||
|
||||
/** @brief Thread queue Enqueue
|
||||
*
|
||||
* This routine enqueues the currently executing thread on
|
||||
* the_thread_queue with an optional timeout.
|
||||
*/
|
||||
void _Thread_queue_Enqueue(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Watchdog_Interval timeout
|
||||
void _Thread_queue_Enqueue_with_handler(
|
||||
Thread_queue_Control* the_thread_queue,
|
||||
Watchdog_Interval timeout,
|
||||
Thread_queue_Timeout_callout handler
|
||||
);
|
||||
|
||||
/** @brief Thread queue Extract
|
||||
@@ -220,6 +243,11 @@ void _Thread_queue_Timeout (
|
||||
void *ignored
|
||||
);
|
||||
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/score/threadq.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -232,6 +232,10 @@ $(PROJECT_INCLUDE)/rtems/score/thread.inl: inline/rtems/score/thread.inl $(PROJE
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/thread.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/thread.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/score/threadq.inl: inline/rtems/score/threadq.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadq.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadq.inl
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/score/tod.inl: inline/rtems/score/tod.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tod.inl
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tod.inl
|
||||
|
||||
@@ -97,7 +97,11 @@ void _CORE_RWLock_Obtain_for_reading(
|
||||
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
|
||||
_ISR_Enable( level );
|
||||
|
||||
_Thread_queue_Enqueue( &the_rwlock->Wait_queue, timeout );
|
||||
_Thread_queue_Enqueue_with_handler(
|
||||
&the_rwlock->Wait_queue,
|
||||
timeout,
|
||||
_CORE_RWLock_Timeout
|
||||
);
|
||||
|
||||
/* return to API level so it can dispatch and we block */
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Thread_queue_Enqueue
|
||||
* _Thread_queue_Enqueue_with_handler
|
||||
*
|
||||
* This routine blocks a thread, places it on a thread, and optionally
|
||||
* starts a timeout timer.
|
||||
@@ -45,9 +45,10 @@
|
||||
* only case
|
||||
*/
|
||||
|
||||
void _Thread_queue_Enqueue(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Watchdog_Interval timeout
|
||||
void _Thread_queue_Enqueue_with_handler(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Watchdog_Interval timeout,
|
||||
Thread_queue_Timeout_callout handler
|
||||
)
|
||||
{
|
||||
Thread_Control *the_thread;
|
||||
@@ -64,7 +65,7 @@ void _Thread_queue_Enqueue(
|
||||
if ( timeout ) {
|
||||
_Watchdog_Initialize(
|
||||
&the_thread->Timer,
|
||||
_Thread_queue_Timeout,
|
||||
handler,
|
||||
the_thread->Object.id,
|
||||
NULL
|
||||
);
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
#include <rtems/score/threadq.h>
|
||||
#include <rtems/score/tqdata.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* _Thread_queue_Timeout
|
||||
*
|
||||
* This routine processes a thread which timeouts while waiting on
|
||||
@@ -44,7 +43,6 @@ void _Thread_queue_Timeout(
|
||||
)
|
||||
{
|
||||
Thread_Control *the_thread;
|
||||
Thread_queue_Control *the_thread_queue;
|
||||
Objects_Locations location;
|
||||
|
||||
the_thread = _Thread_Get( id, &location );
|
||||
@@ -53,28 +51,7 @@ void _Thread_queue_Timeout(
|
||||
case OBJECTS_REMOTE: /* impossible */
|
||||
break;
|
||||
case OBJECTS_LOCAL:
|
||||
the_thread_queue = the_thread->Wait.queue;
|
||||
|
||||
/*
|
||||
* If the_thread_queue is not synchronized, then it is either
|
||||
* "nothing happened", "timeout", or "satisfied". If the_thread
|
||||
* is the executing thread, then it is in the process of blocking
|
||||
* and it is the thread which is responsible for the synchronization
|
||||
* process.
|
||||
*
|
||||
* If it is not satisfied, then it is "nothing happened" and
|
||||
* this is the "timeout" transition. After a request is satisfied,
|
||||
* a timeout is not allowed to occur.
|
||||
*/
|
||||
|
||||
if ( the_thread_queue->sync_state != THREAD_QUEUE_SYNCHRONIZED &&
|
||||
_Thread_Is_executing( the_thread ) ) {
|
||||
if ( the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED )
|
||||
the_thread_queue->sync_state = THREAD_QUEUE_TIMEOUT;
|
||||
} else {
|
||||
the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
|
||||
_Thread_queue_Extract( the_thread->Wait.queue, the_thread );
|
||||
}
|
||||
_Thread_queue_Process_timeout( the_thread );
|
||||
_Thread_Unnest_dispatch();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user