diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-17 16:01:42 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-17 16:01:42 +0000 |
commit | a6cbc9b8690825aebde9694e9132230d57d53847 (patch) | |
tree | 0974c40531822c54d167e4bdea37e57dca40ec9e /cpukit/posix/src/timertsr.c | |
parent | Formatting. (diff) | |
download | rtems-a6cbc9b8690825aebde9694e9132230d57d53847.tar.bz2 |
2007-12-17 Joel Sherrill <joel.sherrill@OARcorp.com>
* posix/Makefile.am, posix/preinstall.am,
posix/include/rtems/posix/timer.h, score/src/objectget.c: Split POSIX
Timer implementation into multiple files. Add obvious error checks
for NULL parameters. Attempt to reduce include files.
* posix/src/timercreate.c, posix/src/timerdelete.c,
posix/src/timergetoverrun.c, posix/src/timergettime.c,
posix/src/timerinserthelper.c, posix/src/timersettime.c,
posix/src/timertsr.c: New files.
* posix/src/ptimer1.c: Removed.
Diffstat (limited to 'cpukit/posix/src/timertsr.c')
-rw-r--r-- | cpukit/posix/src/timertsr.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/cpukit/posix/src/timertsr.c b/cpukit/posix/src/timertsr.c new file mode 100644 index 0000000000..87bd718853 --- /dev/null +++ b/cpukit/posix/src/timertsr.c @@ -0,0 +1,79 @@ +/* + * _POSIX_Timer_TSR + * + * COPYRIGHT (c) 1989-2007. + * 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 <time.h> +#include <pthread.h> +#include <signal.h> + +#include <rtems/system.h> +#include <rtems/seterr.h> +#include <rtems/score/thread.h> +#include <rtems/score/tod.h> +#include <rtems/posix/time.h> +#include <rtems/posix/ptimer.h> +#include <rtems/posix/timer.h> + +/* + * This is the operation that is run when a timer expires + */ +void _POSIX_Timer_TSR(Objects_Id timer, void *data) +{ + POSIX_Timer_Control *ptimer; + boolean activated; + + ptimer = (POSIX_Timer_Control *)data; + + /* Increment the number of expirations. */ + ptimer->overrun = ptimer->overrun + 1; + + /* The timer must be reprogrammed */ + if ( ( ptimer->timer_data.it_interval.tv_sec != 0 ) || + ( ptimer->timer_data.it_interval.tv_nsec != 0 ) ) { + activated = _POSIX_Timer_Insert_helper( + &ptimer->Timer, + ptimer->ticks, + ptimer->Object.id, + _POSIX_Timer_TSR, + ptimer + ); + if ( !activated ) + return; + + /* Store the time when the timer was started again */ + _TOD_Get( &ptimer->time ); + + /* The state really did not change but just to be safe */ + ptimer->state = POSIX_TIMER_STATE_CREATE_RUN; + } else { + /* Indicates that the timer is stopped */ + ptimer->state = POSIX_TIMER_STATE_CREATE_STOP; + } + + /* + * The sending of the signal to the process running the handling function + * specified for that signal is simulated + */ + + if ( pthread_kill ( ptimer->thread_id, ptimer->inf.sigev_signo ) ) { + /* XXX error handling */ + } + + /* After the signal handler returns, the count of expirations of the + * timer must be set to 0. + */ + ptimer->overrun = 0; +} |