OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [alarm.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  alarm.c,v 1.6 2001/01/24 14:17:28 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <pthread.h>
19
/* #include <errno.h> */
20
 
21
#include <rtems/system.h>
22
#include <rtems/posix/pthread.h>
23
#include <rtems/posix/psignal.h>
24
 
25
unsigned int alarm(
26
  unsigned int seconds
27
)
28
{
29
  unsigned int      remaining = 0;
30
  Watchdog_Control *the_timer;
31
 
32
  the_timer = &_POSIX_signals_Alarm_timer;
33
 
34
  switch ( _Watchdog_Remove( the_timer ) ) {
35
    case WATCHDOG_INACTIVE:
36
    case WATCHDOG_BEING_INSERTED:
37
      break;
38
 
39
    case WATCHDOG_ACTIVE:
40
    case WATCHDOG_REMOVE_IT:
41
      /*
42
       *  The stop_time and start_time fields are snapshots of ticks since
43
       *  boot.  Since alarm() is dealing in seconds, we must account for
44
       *  this.
45
       */
46
 
47
      remaining = the_timer->initial -
48
       ((the_timer->stop_time - the_timer->start_time) / _TOD_Ticks_per_second);
49
      break;
50
  }
51
 
52
  _Watchdog_Insert_seconds( the_timer, seconds );
53
 
54
  return remaining;
55
}
56
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.