source: rtems/cpukit/rtems/src/clockset.c @ c0623a99

Last change on this file since c0623a99 was 1ef8e4a8, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 27, 2016 at 8:07:56 PM

score: Avoid Giant lock for set time of day

Update #2555.
Update #2630.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Set the Current TOD
5 *  @ingroup ClassicClock
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/clock.h>
22#include <rtems/score/todimpl.h>
23#include <rtems/config.h>
24
25rtems_status_code rtems_clock_set(
26  const rtems_time_of_day *tod
27)
28{
29  if ( !tod )
30    return RTEMS_INVALID_ADDRESS;
31
32  if ( _TOD_Validate( tod ) ) {
33    Timestamp_Control tod_as_timestamp;
34    uint32_t          seconds;
35    uint32_t          nanoseconds;
36    ISR_lock_Context  lock_context;
37
38    seconds = _TOD_To_seconds( tod );
39    nanoseconds = tod->ticks
40      * rtems_configuration_get_nanoseconds_per_tick();
41    _Timestamp_Set( &tod_as_timestamp, seconds, nanoseconds );
42
43    _TOD_Lock();
44    _TOD_Acquire( &lock_context );
45    _TOD_Set( &tod_as_timestamp, &lock_context );
46    _TOD_Unlock();
47
48    return RTEMS_SUCCESSFUL;
49  }
50
51  return RTEMS_INVALID_CLOCK;
52}
Note: See TracBrowser for help on using the repository browser.