source: rtems/cpukit/score/src/watchdogtick.c @ 99fc1d1d

5
Last change on this file since 99fc1d1d was 03b900d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/16 at 07:36:26

score: Replace watchdog handler implementation

Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * Copyright (c) 2015, 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/score/watchdogimpl.h>
20#include <rtems/score/schedulerimpl.h>
21#include <rtems/score/threaddispatch.h>
22#include <rtems/score/timecounter.h>
23
24void _Watchdog_Do_tickle(
25  Watchdog_Header  *header,
26  uint64_t          now,
27#ifdef RTEMS_SMP
28  ISR_lock_Control *lock,
29#endif
30  ISR_lock_Context *lock_context
31)
32{
33  while ( true ) {
34    Watchdog_Control *the_watchdog;
35
36    the_watchdog = (Watchdog_Control *) header->first;
37
38    if ( the_watchdog == NULL ) {
39      break;
40    }
41
42    if ( the_watchdog->expire <= now ) {
43      Watchdog_Service_routine_entry routine;
44
45      _Watchdog_Next_first( header, the_watchdog );
46      _RBTree_Extract( &header->Watchdogs, &the_watchdog->Node.RBTree );
47      _Watchdog_Set_state( the_watchdog, WATCHDOG_INACTIVE );
48      routine = the_watchdog->routine;
49
50      _ISR_lock_Release_and_ISR_enable( lock, lock_context );
51      ( *routine )( the_watchdog );
52      _ISR_lock_ISR_disable_and_acquire( lock, lock_context );
53    } else {
54      break;
55    }
56  }
57
58  _ISR_lock_Release_and_ISR_enable( lock, lock_context );
59}
60
61void _Watchdog_Tick( Per_CPU_Control *cpu )
62{
63  ISR_lock_Context lock_context;
64  uint64_t         ticks;
65  struct timespec  now;
66
67  if ( _Per_CPU_Is_boot_processor( cpu ) ) {
68    ++_Watchdog_Ticks_since_boot;
69  }
70
71  _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context );
72
73  ticks = cpu->Watchdog.ticks;
74  _Assert( ticks < UINT64_MAX );
75  ++ticks;
76  cpu->Watchdog.ticks = ticks;
77
78  _Watchdog_Tickle(
79    &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
80    ticks,
81    &cpu->Watchdog.Lock,
82    &lock_context
83  );
84
85  _Timecounter_Getnanotime( &now );
86  _Watchdog_Per_CPU_tickle_absolute(
87    cpu,
88    _Watchdog_Ticks_from_timespec( &now )
89  );
90
91  _Scheduler_Tick( cpu );
92}
Note: See TracBrowser for help on using the repository browser.