mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 10:48:06 +08:00
2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>
* inline/rtems/posix/timer.inl, include/rtems/posix/timer.h, inline/rtems/posix/Makefile.am, src/ptimer1.c: Redid the style of src/ptimer1.c. Continued effort to make the POSIX Timer implementation match that of other managers. Added data structures required to use SuperCore Object Handler.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* inline/rtems/posix/timer.inl, include/rtems/posix/timer.h,
|
||||
inline/rtems/posix/Makefile.am, src/ptimer1.c: Redid the
|
||||
style of src/ptimer1.c. Continued effort to make the
|
||||
POSIX Timer implementation match that of other managers.
|
||||
Added data structures required to use SuperCore Object Handler.
|
||||
|
||||
2000-08-15 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/ptimer1.c: Minor formatting fixes.
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
Objects_Control Object;
|
||||
Watchdog_Control Ticker;
|
||||
|
||||
pthread_t thread_id; /* Thread identifier */
|
||||
char state; /* State of the timer */
|
||||
struct sigevent inf; /* Information associated to the timer */
|
||||
@@ -52,6 +55,17 @@ typedef struct {
|
||||
extern int timer_max;
|
||||
extern POSIX_Timer_Control *timer_struct;
|
||||
|
||||
/*
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
RTEMS_EXTERN Objects_Information _POSIX_Timer_Information;
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/posix/timer.inl>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ AUTOMAKE_OPTIONS = foreign 1.4
|
||||
|
||||
#I_FILES= intr.inl
|
||||
I_FILES = cond.inl key.inl mqueue.inl mutex.inl pthread.inl priority.inl \
|
||||
semaphore.inl
|
||||
semaphore.inl timer.inl
|
||||
|
||||
noinst_HEADERS = $(I_FILES)
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* timer.inl
|
||||
*
|
||||
* This file contains the static inline implementation of the inlined routines
|
||||
* from the POSIX Timer 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.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __POSIX_TIMER_inl
|
||||
#define __POSIX_TIMER_inl
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Allocate
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function allocates a timer control block from
|
||||
* the inactive chain of free timer control blocks.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
|
||||
{
|
||||
return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Free
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This routine frees a timer control block to the
|
||||
* inactive chain of free timer control blocks.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
|
||||
POSIX_Timer_Control *the_timer
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Get
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function maps timer IDs to timer control blocks.
|
||||
* If ID corresponds to a local timer, then it returns
|
||||
* the timer control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the returned value is undefined.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
|
||||
Objects_Id id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Timer_Control *)
|
||||
_Objects_Get( &_POSIX_Timer_Information, id, location );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Is_null
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function returns TRUE if the_timer is NULL and FALSE otherwise.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Timer_Is_null (
|
||||
Timer_Control *the_timer
|
||||
)
|
||||
{
|
||||
return (the_timer == NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -47,29 +47,10 @@
|
||||
* Data for the signals
|
||||
*/
|
||||
|
||||
struct sigaction signal_inf[SIGRTMAX];
|
||||
|
||||
/***********************************
|
||||
* Definition of Internal Functions
|
||||
***********************************/
|
||||
|
||||
/* ***************************************************************************
|
||||
* PRINT_MSG_S
|
||||
*
|
||||
* Description: This function write a message in the display.
|
||||
* It is used for debugging and all the calls must be deleted
|
||||
* when the tests finish
|
||||
* ***************************************************************************/
|
||||
|
||||
static void PRINT_MSG_S ( char *msg )
|
||||
{
|
||||
|
||||
#ifdef DEBUG_MESSAGES
|
||||
printf("%s\n", msg);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* ***************************************************************************
|
||||
* TIMER_INITIALIZE_S
|
||||
*
|
||||
@@ -215,8 +196,6 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
|
||||
* expired timer will be stored in "timer_pos". In theory a timer can not
|
||||
* expire if it has not been created or has been deleted */
|
||||
|
||||
PRINT_MSG_S ("FIRE_TIMER_S");
|
||||
|
||||
timer_pos = TIMER_POSITION_F(timer);
|
||||
|
||||
/* Increases the number of expiration of the timer in one unit. */
|
||||
@@ -257,10 +236,8 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
|
||||
|
||||
if( pthread_kill ( timer_struct[timer_pos].thread_id ,
|
||||
timer_struct[timer_pos].inf.sigev_signo ) ) {
|
||||
PRINT_MSG_S ("ERROR_PTHREAD_KILL");
|
||||
} else {
|
||||
PRINT_MSG_S ("SUCCESS_PTHREAD_KILL");
|
||||
}
|
||||
/* XXX error handling */
|
||||
}
|
||||
|
||||
/*
|
||||
* After the signal handler returns, the count of expirations of the
|
||||
@@ -313,8 +290,6 @@ int timer_create(
|
||||
switch (return_v) {
|
||||
case RTEMS_SUCCESSFUL :
|
||||
|
||||
PRINT_MSG_S("SUCCESS: rtems create timer RTEMS_SUCCESSFUL");
|
||||
|
||||
/*
|
||||
* The timer has been created properly
|
||||
*/
|
||||
@@ -359,13 +334,11 @@ int timer_create(
|
||||
|
||||
case RTEMS_INVALID_NAME : /* The assigned name is not valid */
|
||||
|
||||
PRINT_MSG_S ("ERROR: rtems create timer RTEMS_INVALID_NAME");
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
case RTEMS_TOO_MANY :
|
||||
|
||||
/* There has been created too much timers for the same process */
|
||||
PRINT_MSG_S ("ERROR: rtems create timer RTEMS_TOO_MANY ");
|
||||
set_errno_and_return_minus_one( EAGAIN );
|
||||
|
||||
default :
|
||||
@@ -534,8 +507,6 @@ int timer_settime(
|
||||
switch ( return_v ) {
|
||||
case RTEMS_SUCCESSFUL:
|
||||
|
||||
PRINT_MSG_S ("SUCCESS: timer_settime RTEMS_SUCCESSFUL");
|
||||
|
||||
/* The timer has been started and is running */
|
||||
|
||||
/* Actualizes the data of the structure and
|
||||
@@ -559,17 +530,17 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_ID:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_ID");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
case RTEMS_NOT_DEFINED:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_NOT_DEFINED");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
case RTEMS_INVALID_CLOCK:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_CLOCK");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -608,8 +579,6 @@ int timer_settime(
|
||||
switch (return_v) {
|
||||
case RTEMS_SUCCESSFUL:
|
||||
|
||||
PRINT_MSG_S ( "SUCCESS: timer_settime RTEMS_SUCCESSFUL");
|
||||
|
||||
/* The timer has been started and is running */
|
||||
|
||||
/* Actualizes the data of the structure and
|
||||
@@ -634,8 +603,6 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_ID:
|
||||
|
||||
PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_ID");
|
||||
|
||||
/* The timer identifier is not correct. In theory, this
|
||||
* situation can not occur, but the solution is easy */
|
||||
|
||||
@@ -645,8 +612,6 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_NUMBER:
|
||||
|
||||
PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_NUMBER");
|
||||
|
||||
/* In this case, RTEMS fails because the values of timing
|
||||
* are incorrect */
|
||||
|
||||
@@ -668,13 +633,10 @@ int timer_settime(
|
||||
|
||||
/* It does nothing, although it will be probably necessary to
|
||||
* return an error */
|
||||
|
||||
}
|
||||
|
||||
/* To avoid problems */
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
2000-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* inline/rtems/posix/timer.inl, include/rtems/posix/timer.h,
|
||||
inline/rtems/posix/Makefile.am, src/ptimer1.c: Redid the
|
||||
style of src/ptimer1.c. Continued effort to make the
|
||||
POSIX Timer implementation match that of other managers.
|
||||
Added data structures required to use SuperCore Object Handler.
|
||||
|
||||
2000-08-15 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/ptimer1.c: Minor formatting fixes.
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
Objects_Control Object;
|
||||
Watchdog_Control Ticker;
|
||||
|
||||
pthread_t thread_id; /* Thread identifier */
|
||||
char state; /* State of the timer */
|
||||
struct sigevent inf; /* Information associated to the timer */
|
||||
@@ -52,6 +55,17 @@ typedef struct {
|
||||
extern int timer_max;
|
||||
extern POSIX_Timer_Control *timer_struct;
|
||||
|
||||
/*
|
||||
* The following defines the information control block used to manage
|
||||
* this class of objects.
|
||||
*/
|
||||
|
||||
RTEMS_EXTERN Objects_Information _POSIX_Timer_Information;
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/posix/timer.inl>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* timer.inl
|
||||
*
|
||||
* This file contains the static inline implementation of the inlined routines
|
||||
* from the POSIX Timer 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.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __POSIX_TIMER_inl
|
||||
#define __POSIX_TIMER_inl
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Allocate
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function allocates a timer control block from
|
||||
* the inactive chain of free timer control blocks.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
|
||||
{
|
||||
return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Free
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This routine frees a timer control block to the
|
||||
* inactive chain of free timer control blocks.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
|
||||
POSIX_Timer_Control *the_timer
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Get
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function maps timer IDs to timer control blocks.
|
||||
* If ID corresponds to a local timer, then it returns
|
||||
* the timer control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the returned value is undefined.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
|
||||
Objects_Id id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Timer_Control *)
|
||||
_Objects_Get( &_POSIX_Timer_Information, id, location );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Timer_Is_null
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This function returns TRUE if the_timer is NULL and FALSE otherwise.
|
||||
*/
|
||||
|
||||
RTEMS_INLINE_ROUTINE boolean _POSIX_Timer_Is_null (
|
||||
Timer_Control *the_timer
|
||||
)
|
||||
{
|
||||
return (the_timer == NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
@@ -47,29 +47,10 @@
|
||||
* Data for the signals
|
||||
*/
|
||||
|
||||
struct sigaction signal_inf[SIGRTMAX];
|
||||
|
||||
/***********************************
|
||||
* Definition of Internal Functions
|
||||
***********************************/
|
||||
|
||||
/* ***************************************************************************
|
||||
* PRINT_MSG_S
|
||||
*
|
||||
* Description: This function write a message in the display.
|
||||
* It is used for debugging and all the calls must be deleted
|
||||
* when the tests finish
|
||||
* ***************************************************************************/
|
||||
|
||||
static void PRINT_MSG_S ( char *msg )
|
||||
{
|
||||
|
||||
#ifdef DEBUG_MESSAGES
|
||||
printf("%s\n", msg);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* ***************************************************************************
|
||||
* TIMER_INITIALIZE_S
|
||||
*
|
||||
@@ -215,8 +196,6 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
|
||||
* expired timer will be stored in "timer_pos". In theory a timer can not
|
||||
* expire if it has not been created or has been deleted */
|
||||
|
||||
PRINT_MSG_S ("FIRE_TIMER_S");
|
||||
|
||||
timer_pos = TIMER_POSITION_F(timer);
|
||||
|
||||
/* Increases the number of expiration of the timer in one unit. */
|
||||
@@ -257,10 +236,8 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
|
||||
|
||||
if( pthread_kill ( timer_struct[timer_pos].thread_id ,
|
||||
timer_struct[timer_pos].inf.sigev_signo ) ) {
|
||||
PRINT_MSG_S ("ERROR_PTHREAD_KILL");
|
||||
} else {
|
||||
PRINT_MSG_S ("SUCCESS_PTHREAD_KILL");
|
||||
}
|
||||
/* XXX error handling */
|
||||
}
|
||||
|
||||
/*
|
||||
* After the signal handler returns, the count of expirations of the
|
||||
@@ -313,8 +290,6 @@ int timer_create(
|
||||
switch (return_v) {
|
||||
case RTEMS_SUCCESSFUL :
|
||||
|
||||
PRINT_MSG_S("SUCCESS: rtems create timer RTEMS_SUCCESSFUL");
|
||||
|
||||
/*
|
||||
* The timer has been created properly
|
||||
*/
|
||||
@@ -359,13 +334,11 @@ int timer_create(
|
||||
|
||||
case RTEMS_INVALID_NAME : /* The assigned name is not valid */
|
||||
|
||||
PRINT_MSG_S ("ERROR: rtems create timer RTEMS_INVALID_NAME");
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
case RTEMS_TOO_MANY :
|
||||
|
||||
/* There has been created too much timers for the same process */
|
||||
PRINT_MSG_S ("ERROR: rtems create timer RTEMS_TOO_MANY ");
|
||||
set_errno_and_return_minus_one( EAGAIN );
|
||||
|
||||
default :
|
||||
@@ -534,8 +507,6 @@ int timer_settime(
|
||||
switch ( return_v ) {
|
||||
case RTEMS_SUCCESSFUL:
|
||||
|
||||
PRINT_MSG_S ("SUCCESS: timer_settime RTEMS_SUCCESSFUL");
|
||||
|
||||
/* The timer has been started and is running */
|
||||
|
||||
/* Actualizes the data of the structure and
|
||||
@@ -559,17 +530,17 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_ID:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_ID");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
case RTEMS_NOT_DEFINED:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_NOT_DEFINED");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
case RTEMS_INVALID_CLOCK:
|
||||
|
||||
PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_CLOCK");
|
||||
/* XXX error handling */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -608,8 +579,6 @@ int timer_settime(
|
||||
switch (return_v) {
|
||||
case RTEMS_SUCCESSFUL:
|
||||
|
||||
PRINT_MSG_S ( "SUCCESS: timer_settime RTEMS_SUCCESSFUL");
|
||||
|
||||
/* The timer has been started and is running */
|
||||
|
||||
/* Actualizes the data of the structure and
|
||||
@@ -634,8 +603,6 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_ID:
|
||||
|
||||
PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_ID");
|
||||
|
||||
/* The timer identifier is not correct. In theory, this
|
||||
* situation can not occur, but the solution is easy */
|
||||
|
||||
@@ -645,8 +612,6 @@ int timer_settime(
|
||||
|
||||
case RTEMS_INVALID_NUMBER:
|
||||
|
||||
PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_NUMBER");
|
||||
|
||||
/* In this case, RTEMS fails because the values of timing
|
||||
* are incorrect */
|
||||
|
||||
@@ -668,13 +633,10 @@ int timer_settime(
|
||||
|
||||
/* It does nothing, although it will be probably necessary to
|
||||
* return an error */
|
||||
|
||||
}
|
||||
|
||||
/* To avoid problems */
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user