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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [alarm.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: alarm.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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
 
22
unsigned 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
 

powered by: WebSVN 2.1.0

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