summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-08 19:41:31 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-08 19:41:31 +0000
commitc16bcc009b3bec9f653cefbe5247ef9d74352833 (patch)
treebbe12a1ed854be9a8ab090f774b0fc096bb76cc9 /cpukit/score/src
parent2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-c16bcc009b3bec9f653cefbe5247ef9d74352833.tar.bz2
2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/__times.c, libmisc/cpuuse/cpuusagereport.c, libmisc/cpuuse/cpuusagereset.c, posix/src/clockgettime.c, posix/src/pthread.c, posix/src/timersettime.c, rtems/include/rtems/rtems/ratemon.h, rtems/src/clockgetsecondssinceepoch.c, rtems/src/clockgetuptime.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonreportstatistics.c, rtems/src/taskwakewhen.c, rtems/src/timerfirewhen.c, rtems/src/timerserver.c, rtems/src/timerserverfirewhen.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/thread.h, score/include/rtems/score/tod.h, score/src/coretod.c, score/src/coretodget.c, score/src/coretodgetuptime.c, score/src/coretodset.c, score/src/coretodtickle.c, score/src/threaddispatch.c, score/src/threadinitialize.c: Add SuperCore handler Timestamp to provide an opaque class for the representation and manipulation of uptime, time of day, and the difference between two timestamps. By using SuperCore Timestamp, it is clear which methods and APIs really have to be struct timespec and which can be in an optimized native format. * score/include/rtems/score/timestamp.h, score/src/coretodgetuptimetimespec.c: New files.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/coretod.c6
-rw-r--r--cpukit/score/src/coretodget.c23
-rw-r--r--cpukit/score/src/coretodgetuptime.c26
-rw-r--r--cpukit/score/src/coretodgetuptimetimespec.c44
-rw-r--r--cpukit/score/src/coretodset.c17
-rw-r--r--cpukit/score/src/coretodtickle.c15
-rw-r--r--cpukit/score/src/threaddispatch.c12
-rw-r--r--cpukit/score/src/threadinitialize.c3
8 files changed, 99 insertions, 47 deletions
diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
index fbadaf673d..cf4ec8e334 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -41,12 +41,10 @@ void _TOD_Handler_initialization(
_TOD_Microseconds_per_tick = microseconds_per_tick;
/* POSIX format TOD (timespec) */
- _TOD_Now.tv_sec = TOD_SECONDS_1970_THROUGH_1988;
- _TOD_Now.tv_nsec = 0;
+ _Timestamp_Set( &_TOD_Now, TOD_SECONDS_1970_THROUGH_1988, 0 );
/* Uptime (timespec) */
- _TOD_Uptime.tv_sec = 0;
- _TOD_Uptime.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &_TOD_Uptime );
/* TOD has not been set */
_TOD_Is_set = FALSE;
diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c
index 1d48082f26..dff46a0748 100644
--- a/cpukit/score/src/coretodget.c
+++ b/cpukit/score/src/coretodget.c
@@ -18,6 +18,7 @@
#include <rtems/system.h>
#include <rtems/score/isr.h>
#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -36,20 +37,22 @@ void _TOD_Get(
struct timespec *time
)
{
- ISR_Level level;
- struct timespec offset;
+ ISR_Level level;
+ Timestamp_Control offset;
+ Timestamp_Control now;
+ long nanoseconds;
- /* assume time checked by caller */
+ /* assume time checked for NULL by caller */
- offset.tv_sec = 0;
- offset.tv_nsec = 0;
-
- /* _TOD_Now is a proper POSIX time */
+ /* _TOD_Now is the native current time */
+ nanoseconds = 0;
_ISR_Disable( level );
- *time = _TOD_Now;
+ now = _TOD_Now;
if ( _Watchdog_Nanoseconds_since_tick_handler )
- offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();
+ nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
_ISR_Enable( level );
- _Timespec_Add_to( time, &offset );
+ _Timestamp_Set( &offset, 0, nanoseconds );
+ _Timestamp_Add_to( &now, &offset );
+ _Timestamp_To_timespec( &now, time );
}
diff --git a/cpukit/score/src/coretodgetuptime.c b/cpukit/score/src/coretodgetuptime.c
index 7155419f34..6d4e5dc72a 100644
--- a/cpukit/score/src/coretodgetuptime.c
+++ b/cpukit/score/src/coretodgetuptime.c
@@ -18,7 +18,7 @@
#include <rtems/system.h>
#include <rtems/score/isr.h>
-#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -28,28 +28,30 @@
* This routine is used to obtain the system uptime
*
* Input parameters:
- * time - pointer to the time and date structure
+ * time - pointer to the timestamp structure
*
* Output parameters: NONE
*/
void _TOD_Get_uptime(
- struct timespec *uptime
+ Timestamp_Control *uptime
)
{
- ISR_Level level;
- struct timespec offset;
+ ISR_Level level;
+ Timestamp_Control offset;
+ Timestamp_Control up;
+ long nanoseconds;
- /* assume uptime checked by caller */
-
- offset.tv_sec = 0;
- offset.tv_nsec = 0;
+ /* assume time checked for NULL by caller */
+ /* _TOD_Uptime is in native timestamp format */
+ nanoseconds = 0;
_ISR_Disable( level );
- *uptime = _TOD_Uptime;
+ up= _TOD_Uptime;
if ( _Watchdog_Nanoseconds_since_tick_handler )
- offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();
+ nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
_ISR_Enable( level );
- _Timespec_Add_to( uptime, &offset );
+ _Timestamp_Set( &offset, 0, nanoseconds );
+ _Timestamp_Add_to( &up, &offset );
}
diff --git a/cpukit/score/src/coretodgetuptimetimespec.c b/cpukit/score/src/coretodgetuptimetimespec.c
new file mode 100644
index 0000000000..6d30a95d9c
--- /dev/null
+++ b/cpukit/score/src/coretodgetuptimetimespec.c
@@ -0,0 +1,44 @@
+/*
+ * Time of Day (TOD) Handler - get uptime
+ */
+
+/* COPYRIGHT (c) 1989-2008.
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/timestamp.h>
+#include <rtems/score/tod.h>
+
+/*
+ * _TOD_Get_uptime_as_timespec
+ *
+ * This routine is used to obtain the system uptime
+ *
+ * Input parameters:
+ * time - pointer to the timestamp structure
+ *
+ * Output parameters: NONE
+ */
+
+void _TOD_Get_uptime_as_timespec(
+ struct timespec *uptime
+)
+{
+ Timestamp_Control uptime_ts;
+
+ /* assume time checked for NULL by caller */
+ _TOD_Get_uptime( &uptime_ts );
+ _Timestamp_To_timespec( &uptime_ts, uptime );
+}
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index c34f571e30..fea26dd190 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -19,6 +19,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -39,19 +40,21 @@ void _TOD_Set(
const struct timespec *time
)
{
+ long seconds;
+
_Thread_Disable_dispatch();
_TOD_Deactivate();
- if ( time->tv_sec < _TOD_Seconds_since_epoch )
- _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
- _TOD_Seconds_since_epoch - time->tv_sec );
+ seconds = _TOD_Seconds_since_epoch();
+
+ if ( time->tv_sec < seconds )
+ _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec );
else
- _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
- time->tv_sec - _TOD_Seconds_since_epoch );
+ _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds );
/* POSIX format TOD (timespec) */
- _TOD_Now = *time;
- _TOD_Is_set = TRUE;
+ _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec );
+ _TOD_Is_set = TRUE;
_TOD_Activate();
diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c
index 1afef420a2..f4e5a4f69c 100644
--- a/cpukit/score/src/coretodtickle.c
+++ b/cpukit/score/src/coretodtickle.c
@@ -19,7 +19,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
-#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -36,22 +36,21 @@
void _TOD_Tickle_ticks( void )
{
- struct timespec tick;
- uint32_t seconds;
+ Timestamp_Control tick;
+ uint32_t seconds;
- /* Convert the tick quantum to a timespec */
- tick.tv_nsec = _TOD_Microseconds_per_tick * 1000;
- tick.tv_sec = 0;
+ /* Convert the tick quantum to a timestamp */
+ _Timestamp_Set( &tick, 0, _TOD_Microseconds_per_tick * 1000 );
/* Update the counter of ticks since boot */
_Watchdog_Ticks_since_boot += 1;
/* Update the timespec format uptime */
- (void) _Timespec_Add_to( &_TOD_Uptime, &tick );
+ _Timestamp_Add_to( &_TOD_Uptime, &tick );
/* we do not care how much the uptime changed */
/* Update the timespec format TOD */
- seconds = _Timespec_Add_to( &_TOD_Now, &tick );
+ seconds = _Timestamp_Add_to_at_tick( &_TOD_Now, &tick );
while ( seconds ) {
_Watchdog_Tickle_seconds();
seconds--;
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 4911ab5342..45a4a45ebe 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -31,7 +31,7 @@
#include <rtems/score/wkspace.h>
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- #include <rtems/score/timespec.h>
+ #include <rtems/score/timestamp.h>
#endif
/*PAGE
@@ -103,10 +103,14 @@ void _Thread_Dispatch( void )
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
{
- struct timespec uptime, ran;
+ Timestamp_Control uptime, ran;
_TOD_Get_uptime( &uptime );
- _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
- _Timespec_Add_to( &executing->cpu_time_used, &ran );
+ _Timestamp_Subtract(
+ &_Thread_Time_of_last_context_switch,
+ &uptime,
+ &ran
+ );
+ _Timestamp_Add_to( &executing->cpu_time_used, &ran );
_Thread_Time_of_last_context_switch = uptime;
}
#else
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 596fe365a0..b7e504ca4a 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -206,8 +206,7 @@ bool _Thread_Initialize(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- the_thread->cpu_time_used.tv_sec = 0;
- the_thread->cpu_time_used.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
#else
the_thread->cpu_time_used = 0;
#endif