source: rtems/cpukit/score/src/coretodset.c @ 4fc370e

4.115
Last change on this file since 4fc370e 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
RevLine 
[1b475860]1/**
2 * @file
3 *
4 * @brief Set Time of Day Given a Timestamp
5 *
6 * @ingroup ScoreTOD
[412dbff6]7 */
8
9/*  COPYRIGHT (c) 1989-2007.
[93b4e6ef]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
[dd687d9]14 *  http://www.rtems.com/license/LICENSE.
[93b4e6ef]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[93b4e6ef]21#include <rtems/system.h>
22#include <rtems/score/object.h>
23#include <rtems/score/thread.h>
[4fc370e]24#include <rtems/score/threaddispatch.h>
[c16bcc0]25#include <rtems/score/timestamp.h>
[93b4e6ef]26#include <rtems/score/tod.h>
27#include <rtems/score/watchdog.h>
28
[8d7aea0d]29void _TOD_Set_with_timestamp(
30  const Timestamp_Control *tod
[93b4e6ef]31)
32{
[c34bb0d]33  uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod );
[8d7aea0d]34  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
35  Watchdog_Interval seconds_now;
[c16bcc0]36
[93b4e6ef]37  _Thread_Disable_dispatch();
38  _TOD_Deactivate();
39
[8d7aea0d]40  seconds_now = _TOD_Seconds_since_epoch();
[c16bcc0]41
[8d7aea0d]42  if ( seconds_next < seconds_now )
43    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
[93b4e6ef]44  else
[8d7aea0d]45    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
[93b4e6ef]46
[3246b0f8]47  _TOD.now = *tod;
[c34bb0d]48  _TOD.seconds_trigger = nanoseconds;
[3246b0f8]49  _TOD.is_set = true;
[812da54]50
[b272001]51  _TOD_Activate();
[93b4e6ef]52  _Thread_Enable_dispatch();
53}
Note: See TracBrowser for help on using the repository browser.