source: rtems/cpukit/score/src/coretodset.c @ c398c66

4.115
Last change on this file since c398c66 was 4fc370e, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 5, 2013 at 10:08:23 AM

score: Move thread dispatch content to new file

Move thread dispatch declarations and inline functions to new header
<rtems/score/threaddispatch.h> to make it independent of the
Thread_Control structure. This avoids a cyclic dependency in case
thread dispatch functions are used for the object implementation.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Time of Day Given a Timestamp
5 *
6 * @ingroup ScoreTOD
7 */
8
9/*  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/object.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/threaddispatch.h>
25#include <rtems/score/timestamp.h>
26#include <rtems/score/tod.h>
27#include <rtems/score/watchdog.h>
28
29void _TOD_Set_with_timestamp(
30  const Timestamp_Control *tod
31)
32{
33  uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod );
34  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
35  Watchdog_Interval seconds_now;
36
37  _Thread_Disable_dispatch();
38  _TOD_Deactivate();
39
40  seconds_now = _TOD_Seconds_since_epoch();
41
42  if ( seconds_next < seconds_now )
43    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
44  else
45    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
46
47  _TOD.now = *tod;
48  _TOD.seconds_trigger = nanoseconds;
49  _TOD.is_set = true;
50
51  _TOD_Activate();
52  _Thread_Enable_dispatch();
53}
Note: See TracBrowser for help on using the repository browser.