source: rtems/cpukit/posix/src/timertsr.c @ f8437c8

4.104.114.95
Last change on this file since f8437c8 was f8437c8, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 15:23:12

Convert to "bool".

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * _POSIX_Timer_TSR
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <time.h>
19#include <pthread.h>
20#include <signal.h>
21
22#include <rtems/system.h>
23#include <rtems/seterr.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/tod.h>
26#include <rtems/posix/time.h>
27#include <rtems/posix/ptimer.h>
28#include <rtems/posix/timer.h>
29
30/*
31 *  This is the operation that is run when a timer expires
32 */
33void _POSIX_Timer_TSR(Objects_Id timer, void *data)
34{
35  POSIX_Timer_Control *ptimer;
36  bool                 activated;
37
38  ptimer = (POSIX_Timer_Control *)data;
39
40  /* Increment the number of expirations. */
41  ptimer->overrun = ptimer->overrun + 1;
42
43  /* The timer must be reprogrammed */
44  if ( ( ptimer->timer_data.it_interval.tv_sec  != 0 ) ||
45       ( ptimer->timer_data.it_interval.tv_nsec != 0 ) ) {
46    activated = _POSIX_Timer_Insert_helper(
47      &ptimer->Timer,
48      ptimer->ticks,
49      ptimer->Object.id,
50      _POSIX_Timer_TSR,
51      ptimer
52    );
53    if ( !activated )
54      return;
55
56    /* Store the time when the timer was started again */
57    _TOD_Get( &ptimer->time );
58
59    /* The state really did not change but just to be safe */
60    ptimer->state = POSIX_TIMER_STATE_CREATE_RUN;
61  } else {
62   /* Indicates that the timer is stopped */
63   ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
64  }
65
66  /*
67   * The sending of the signal to the process running the handling function
68   * specified for that signal is simulated
69   */
70
71  if ( pthread_kill ( ptimer->thread_id, ptimer->inf.sigev_signo ) ) {
72    /* XXX error handling */
73  }
74
75  /* After the signal handler returns, the count of expirations of the
76   * timer must be set to 0.
77   */
78  ptimer->overrun = 0;
79}
Note: See TracBrowser for help on using the repository browser.