[rtems commit] score: Fix _TOD_Set_with_timestamp()
Sebastian Huber
sebh at rtems.org
Fri Apr 17 06:38:40 UTC 2015
Module: rtems
Branch: master
Commit: a211a732fd987057a30db919127a322f151d5f1f
Changeset: http://git.rtems.org/rtems/commit/?id=a211a732fd987057a30db919127a322f151d5f1f
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Apr 16 22:24:59 2015 +0200
score: Fix _TOD_Set_with_timestamp()
Update the current time before the watchdog adjust so that timer
routines observe the new time.
---
cpukit/score/src/coretodset.c | 9 +++++----
testsuites/sptests/sp52/init.c | 35 ++++++++++++++++++++---------------
2 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index 7c7731a..3d11758 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -36,6 +36,11 @@ void _TOD_Set_with_timestamp(
_Thread_Disable_dispatch();
seconds_now = _TOD_Seconds_since_epoch();
+
+ _TOD_Acquire( tod, &lock_context );
+ tod->now = *tod_as_timestamp;
+ _TOD_Release( tod, &lock_context );
+
header = &_Watchdog_Seconds_header;
if ( seconds_next < seconds_now )
@@ -43,10 +48,6 @@ void _TOD_Set_with_timestamp(
else
_Watchdog_Adjust_forward( header, seconds_next - seconds_now );
- _TOD_Acquire( tod, &lock_context );
- tod->now = *tod_as_timestamp;
- _TOD_Release( tod, &lock_context );
-
tod->seconds_trigger = nanoseconds;
tod->is_set = true;
diff --git a/testsuites/sptests/sp52/init.c b/testsuites/sptests/sp52/init.c
index f003d1c..d675e4f 100644
--- a/testsuites/sptests/sp52/init.c
+++ b/testsuites/sptests/sp52/init.c
@@ -26,29 +26,35 @@
#endif
#include <tmacros.h>
+#include <string.h>
const char rtems_test_name[] = "SP " TEST_NUMBER;
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-rtems_timer_service_routine TIMER_service_routine(
- rtems_id ignored_id,
- void *user_data
-);
+#define INITIAL_YEAR 2009
-#define INITIAL_SECOND 10
-volatile bool _timer_passage = FALSE;
+static bool _timer_passage;
+
+static rtems_time_of_day time_to_fire;
/*timer Routine*/
-rtems_timer_service_routine TIMER_service_routine(
+static rtems_timer_service_routine TIMER_service_routine(
rtems_id ignored_id,
void *user_data
)
{
- _timer_passage = TRUE;
+ rtems_status_code status;
+ rtems_time_of_day now;
+
+ _timer_passage = true;
+
+ memset( &now, 0, sizeof( now ) );
+
+ status = rtems_clock_get_tod( &now );
+ rtems_test_assert( status == RTEMS_SUCCESSFUL );
+ rtems_test_assert( memcmp( &now, &time_to_fire, sizeof( now ) ) == 0 );
}
-rtems_task Init(
+static rtems_task Init(
rtems_task_argument argument
)
{
@@ -57,7 +63,6 @@ rtems_task Init(
rtems_name timer_name;
rtems_time_of_day global_time;
- rtems_time_of_day time_to_fire;
TEST_BEGIN();
@@ -79,7 +84,7 @@ rtems_task Init(
#endif
/* Set system clock */
- build_time(&global_time, 6, 8, 2009, 16, 5, INITIAL_SECOND, 0);
+ build_time(&global_time, 6, 8, INITIAL_YEAR, 16, 5, 13, 0);
status = rtems_clock_set(&global_time);
directive_failed( status, "rtems_clock_set" );
@@ -88,7 +93,7 @@ rtems_task Init(
time_to_fire = global_time;
/* only diferent second */
- time_to_fire.second = INITIAL_SECOND + 5;
+ time_to_fire.year = INITIAL_YEAR + 5;
status = FIRE_WHEN(
timer_id,
@@ -99,7 +104,7 @@ rtems_task Init(
directive_failed( status, FIRE_WHEN_STRING );
/* Set system clock FORWARD */
- global_time.second = INITIAL_SECOND + 10;
+ global_time.year = time_to_fire.year;
status = rtems_clock_set(&global_time);
if (!_timer_passage) {
More information about the vc
mailing list