summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-10 15:31:31 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:43 +0200
commita382010c62455df73552eb5f0baa1faebe9702c7 (patch)
tree32764a1f1ce7aec8cd5dce3bf4a363ec4c2de179 /cpukit/score
parentscore: Move _Watchdog_Tickle() (diff)
downloadrtems-a382010c62455df73552eb5f0baa1faebe9702c7.tar.bz2
score: New timer server implementation
Use mostly the standard watchdog operations. Use a system event for synchronization. This implementation is simpler and offers better SMP performance. Close #2131.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/Makefile.am2
-rw-r--r--cpukit/score/include/rtems/score/watchdogimpl.h59
-rw-r--r--cpukit/score/src/watchdogadjust.c35
-rw-r--r--cpukit/score/src/watchdogadjusttochain.c75
-rw-r--r--cpukit/score/src/watchdoginsert.c21
5 files changed, 84 insertions, 108 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index af7da2ac53..3eb2caa902 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -324,7 +324,7 @@ libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
## WATCHDOG_C_FILES
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
- src/watchdogadjusttochain.c src/watchdoginsert.c src/watchdogremove.c
+ src/watchdoginsert.c src/watchdogremove.c
libscore_a_SOURCES += src/watchdogtickssinceboot.c
## USEREXT_C_FILES
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index dfe50e6d3a..6804bf24d4 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -165,6 +165,22 @@ void _Watchdog_Adjust_backward(
);
/**
+ * @brief Adjusts the watchdogs in backward direction in a locked context.
+ *
+ * The caller must be the owner of the watchdog lock and will be the owner
+ * after the call.
+ *
+ * @param[in] header The watchdog header.
+ * @param[in] units The units of ticks to adjust.
+ *
+ * @see _Watchdog_Adjust_forward().
+ */
+void _Watchdog_Adjust_backward_locked(
+ Watchdog_Header *header,
+ Watchdog_Interval units
+);
+
+/**
* @brief Adjusts the header watchdog chain in the forward direction for units
* ticks.
*
@@ -179,24 +195,22 @@ void _Watchdog_Adjust_forward(
);
/**
- * @brief Adjusts the @a header watchdog chain in the forward
- * @a direction for @a units_arg ticks.
+ * @brief Adjusts the watchdogs in forward direction in a locked context.
*
- * This routine adjusts the @a header watchdog chain in the forward
- * @a direction for @a units_arg ticks.
+ * The caller must be the owner of the watchdog lock and will be the owner
+ * after the call. This function may release and acquire the watchdog lock
+ * internally.
*
- * @param[in] header is the watchdog chain to adjust
- * @param[in] units_arg is the number of units to adjust @a header
- * @param[in] to_fire is a pointer to an initialized Chain_Control to which
- * all watchdog instances that are to be fired will be placed.
+ * @param[in] header The watchdog header.
+ * @param[in] units The units of ticks to adjust.
+ * @param[in] lock_context The lock context.
*
- * @note This always adjusts forward.
+ * @see _Watchdog_Adjust_forward().
*/
-void _Watchdog_Adjust_to_chain(
+void _Watchdog_Adjust_forward_locked(
Watchdog_Header *header,
- Watchdog_Interval units_arg,
- Chain_Control *to_fire
-
+ Watchdog_Interval units,
+ ISR_lock_Context *lock_context
);
/**
@@ -216,6 +230,25 @@ void _Watchdog_Insert (
);
/**
+ * @brief Inserts the watchdog in a locked context.
+ *
+ * The caller must be the owner of the watchdog lock and will be the owner
+ * after the call. This function may release and acquire the watchdog lock
+ * internally.
+ *
+ * @param[in] header The watchdog header.
+ * @param[in] the_watchdog The watchdog.
+ * @param[in] lock_context The lock context.
+ *
+ * @see _Watchdog_Insert().
+ */
+void _Watchdog_Insert_locked(
+ Watchdog_Header *header,
+ Watchdog_Control *the_watchdog,
+ ISR_lock_Context *lock_context
+);
+
+/**
* @brief This routine is invoked at appropriate intervals to update
* the @a header watchdog chain.
*
diff --git a/cpukit/score/src/watchdogadjust.c b/cpukit/score/src/watchdogadjust.c
index 04fc1a55a7..32b5f7990e 100644
--- a/cpukit/score/src/watchdogadjust.c
+++ b/cpukit/score/src/watchdogadjust.c
@@ -19,26 +19,18 @@
#endif
#include <rtems/score/watchdogimpl.h>
-#include <rtems/score/chainimpl.h>
-#include <rtems/score/isrlevel.h>
-void _Watchdog_Adjust_backward(
+void _Watchdog_Adjust_backward_locked(
Watchdog_Header *header,
Watchdog_Interval units
)
{
- ISR_lock_Context lock_context;
-
- _Watchdog_Acquire( header, &lock_context );
-
if ( !_Watchdog_Is_empty( header ) ) {
_Watchdog_First( header )->delta_interval += units;
}
-
- _Watchdog_Release( header, &lock_context );
}
-void _Watchdog_Adjust_forward(
+void _Watchdog_Adjust_backward(
Watchdog_Header *header,
Watchdog_Interval units
)
@@ -46,7 +38,16 @@ void _Watchdog_Adjust_forward(
ISR_lock_Context lock_context;
_Watchdog_Acquire( header, &lock_context );
+ _Watchdog_Adjust_backward_locked( header, units );
+ _Watchdog_Release( header, &lock_context );
+}
+void _Watchdog_Adjust_forward_locked(
+ Watchdog_Header *header,
+ Watchdog_Interval units,
+ ISR_lock_Context *lock_context
+)
+{
while ( !_Watchdog_Is_empty( header ) && units > 0 ) {
Watchdog_Control *first = _Watchdog_First( header );
@@ -57,13 +58,23 @@ void _Watchdog_Adjust_forward(
units -= first->delta_interval;
first->delta_interval = 1;
- _Watchdog_Release( header, &lock_context );
+ _Watchdog_Release( header, lock_context );
_Watchdog_Tickle( header );
- _Watchdog_Acquire( header, &lock_context );
+ _Watchdog_Acquire( header, lock_context );
}
}
+}
+void _Watchdog_Adjust_forward(
+ Watchdog_Header *header,
+ Watchdog_Interval units
+)
+{
+ ISR_lock_Context lock_context;
+
+ _Watchdog_Acquire( header, &lock_context );
+ _Watchdog_Adjust_forward_locked( header, units, &lock_context );
_Watchdog_Release( header, &lock_context );
}
diff --git a/cpukit/score/src/watchdogadjusttochain.c b/cpukit/score/src/watchdogadjusttochain.c
deleted file mode 100644
index b3063e4109..0000000000
--- a/cpukit/score/src/watchdogadjusttochain.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @file
- *
- * @brief Watchdog Adjust to Chain
- * @ingroup ScoreWatchdog
- */
-
-/*
- * COPYRIGHT (c) 1989-2009.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/score/watchdogimpl.h>
-#include <rtems/score/isrlevel.h>
-
-void _Watchdog_Adjust_to_chain(
- Watchdog_Header *header,
- Watchdog_Interval units_arg,
- Chain_Control *to_fire
-
-)
-{
- Watchdog_Interval units = units_arg;
- ISR_lock_Context lock_context;
- Watchdog_Control *first;
-
- _Watchdog_Acquire( header, &lock_context );
-
- while ( 1 ) {
- if ( _Watchdog_Is_empty( header ) ) {
- break;
- }
- first = _Watchdog_First( header );
-
- /*
- * If it is longer than "units" until the first element on the chain
- * fires, then bump it and quit.
- */
- if ( units < first->delta_interval ) {
- first->delta_interval -= units;
- break;
- }
-
- /*
- * The first set happens in less than units, so take all of them
- * off the chain and adjust units to reflect this.
- */
- units -= first->delta_interval;
- first->delta_interval = 0;
-
- while ( 1 ) {
- _Chain_Extract_unprotected( &first->Node );
- _Chain_Append_unprotected( to_fire, &first->Node );
-
- _Watchdog_Flash( header, &lock_context );
-
- if ( _Watchdog_Is_empty( header ) )
- break;
- first = _Watchdog_First( header );
- if ( first->delta_interval != 0 )
- break;
- }
- }
-
- _Watchdog_Release( header, &lock_context );
-}
-
diff --git a/cpukit/score/src/watchdoginsert.c b/cpukit/score/src/watchdoginsert.c
index 6d2df8222f..6b81c7b872 100644
--- a/cpukit/score/src/watchdoginsert.c
+++ b/cpukit/score/src/watchdoginsert.c
@@ -47,15 +47,12 @@ static void _Watchdog_Insert_fixup(
}
}
-void _Watchdog_Insert(
+void _Watchdog_Insert_locked(
Watchdog_Header *header,
- Watchdog_Control *the_watchdog
+ Watchdog_Control *the_watchdog,
+ ISR_lock_Context *lock_context
)
{
- ISR_lock_Context lock_context;
-
- _Watchdog_Acquire( header, &lock_context );
-
if ( the_watchdog->state == WATCHDOG_INACTIVE ) {
Watchdog_Iterator iterator;
Chain_Node *current;
@@ -86,7 +83,7 @@ void _Watchdog_Insert(
iterator.delta_interval = delta - delta_next;
iterator.current = next;
- _Watchdog_Flash( header, &lock_context );
+ _Watchdog_Flash( header, lock_context );
if ( the_watchdog->state != WATCHDOG_BEING_INSERTED ) {
goto abort_insert;
@@ -105,6 +102,16 @@ abort_insert:
_Chain_Extract_unprotected( &iterator.Node );
}
+}
+void _Watchdog_Insert(
+ Watchdog_Header *header,
+ Watchdog_Control *the_watchdog
+)
+{
+ ISR_lock_Context lock_context;
+
+ _Watchdog_Acquire( header, &lock_context );
+ _Watchdog_Insert_locked( header, the_watchdog, &lock_context );
_Watchdog_Release( header, &lock_context );
}