source: rtems/cpukit/score/src/coretodset.c @ 6af81435

4.104.114.84.95
Last change on this file since 6af81435 was 93b4e6ef, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 21:05:17

Split Heap and Time of Day Handlers.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  Time of Day (TOD) Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/object.h>
18#include <rtems/score/thread.h>
19#include <rtems/score/tod.h>
20#include <rtems/score/watchdog.h>
21
22/*PAGE
23 *
24 *  _TOD_Set
25 *
26 *  This rountine sets the current date and time with the specified
27 *  new date and time structure.
28 *
29 *  Input parameters:
30 *    the_tod             - pointer to the time and date structure
31 *    seconds_since_epoch - seconds since system epoch
32 *
33 *  Output parameters: NONE
34 */
35
36void _TOD_Set(
37  TOD_Control *the_tod,
38  Watchdog_Interval  seconds_since_epoch
39)
40{
41  Watchdog_Interval ticks_until_next_second;
42
43  _Thread_Disable_dispatch();
44  _TOD_Deactivate();
45
46  if ( seconds_since_epoch < _TOD_Seconds_since_epoch )
47    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
48       _TOD_Seconds_since_epoch - seconds_since_epoch );
49  else
50    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
51       seconds_since_epoch - _TOD_Seconds_since_epoch );
52
53  ticks_until_next_second = _TOD_Ticks_per_second;
54  if ( ticks_until_next_second > _TOD_Current.ticks )
55    ticks_until_next_second -= _TOD_Current.ticks;
56
57  _TOD_Current             = *the_tod;
58  _TOD_Seconds_since_epoch = seconds_since_epoch;
59  _TOD_Is_set              = TRUE;
60  _TOD_Activate( ticks_until_next_second );
61
62  _Thread_Enable_dispatch();
63}
64
Note: See TracBrowser for help on using the repository browser.