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

4.115
Last change on this file since a0e6c73 was a0e6c73, checked in by Mathew Kallada <matkallada@…>, on 12/14/12 at 01:51:15

posix: Doxygen enhancement task #4

http://www.google-melange.com/gci/task/view/google/gci2012/7955219

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