source: rtems/c/src/exec/posix/src/alarm.c @ b978374

4.104.114.84.95
Last change on this file since b978374 was b978374, checked in by Joel Sherrill <joel.sherrill@…>, on 01/23/01 at 22:42:58

2001-01-23 Joel Sherrill <joel@…>

  • src/alarm.c: Eliminated use of C++ style comments.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  3.4.1 Schedule Alarm, P1003.1b-1993, p. 79
3 *
4 *  COPYRIGHT (c) 1989-1999.
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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14
15#include <pthread.h>
16/* #include <errno.h> */
17
18#include <rtems/system.h>
19#include <rtems/posix/pthread.h>
20#include <rtems/posix/psignal.h>
21
22unsigned int alarm(
23  unsigned int seconds
24)
25{
26  unsigned int      remaining = 0;
27  Watchdog_Control *the_timer;
28
29  the_timer = &_POSIX_signals_Alarm_timer;
30
31  switch ( _Watchdog_Remove( the_timer ) ) {
32    case WATCHDOG_INACTIVE:
33    case WATCHDOG_BEING_INSERTED:
34      break;
35
36    case WATCHDOG_ACTIVE:
37    case WATCHDOG_REMOVE_IT:
38      /*
39       *  The stop_time and start_time fields are snapshots of ticks since
40       *  boot.  Since alarm() is dealing in seconds, we must account for
41       *  this.
42       */
43
44      remaining = the_timer->initial -
45       ((the_timer->stop_time - the_timer->start_time) / _TOD_Ticks_per_second);
46      break;
47  }
48
49  _Watchdog_Insert_seconds( the_timer, seconds );
50
51  return remaining;
52}
53
Note: See TracBrowser for help on using the repository browser.