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.
This commit is contained in:
Joel Sherrill committed 2008-12-08 19:41:31 +00:00
1 parent 6d10c295ee
commit c16bcc009b
30 files changed
+573 -159

No files matched your search

+24
View File
@@ -1,3 +1,27 @@
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.
2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* libfs/src/nfsclient/src/nfs.c: Use
+11 -10
View File
@@ -1,7 +1,7 @@
/*
* times() - POSIX 1003.1b 4.5.2 - Get Process Times
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -23,7 +23,7 @@
#include <errno.h>
#include <assert.h>
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
#include <rtems/score/timespec.h>
#include <rtems/score/timestamp.h>
#endif
clock_t _times(
@@ -53,16 +53,17 @@ clock_t _times(
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
{
struct timespec per_tick;
uint32_t ticks;
uint32_t fractional_ticks;
Timestamp_Control per_tick;
uint32_t ticks;
uint32_t fractional_ticks;
per_tick.tv_sec =
_TOD_Microseconds_per_tick / TOD_MILLISECONDS_PER_SECOND;
per_tick.tv_nsec =
(_TOD_Microseconds_per_tick % TOD_MILLISECONDS_PER_SECOND) / 1000;
_Timestamp_Set(
&per_tick,
_TOD_Microseconds_per_tick / TOD_MILLISECONDS_PER_SECOND,
(_TOD_Microseconds_per_tick % TOD_MILLISECONDS_PER_SECOND) / 1000
);
_Timespec_Divide(
_Timestamp_Divide(
&_Thread_Executing->cpu_time_used,
&per_tick,
&ticks,
+13 -11
View File
@@ -28,11 +28,11 @@
#include <rtems/bspIo.h>
#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
#include <rtems/score/timespec.h>
#include <rtems/score/timestamp.h>
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
extern struct timespec CPU_usage_Uptime_at_last_reset;
extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
extern uint32_t CPU_usage_Ticks_at_last_reset;
#endif
@@ -54,7 +54,7 @@ void rtems_cpu_usage_report_with_plugin(
char name[13];
uint32_t ival, fval;
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
struct timespec uptime, total, ran;
Timestamp_Control uptime, total, ran;
#else
uint32_t total_units = 0;
#endif
@@ -69,7 +69,7 @@ void rtems_cpu_usage_report_with_plugin(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
_TOD_Get_uptime( &uptime );
_Timespec_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
_Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
#else
for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
if ( !_Objects_Information_table[ api_index ] )
@@ -123,13 +123,13 @@ void rtems_cpu_usage_report_with_plugin(
*/
ran = the_thread->cpu_time_used;
if ( _Thread_Executing->Object.id == the_thread->Object.id ) {
struct timespec used;
_Timespec_Subtract(
Timestamp_Control used;
_Timestamp_Subtract(
&_Thread_Time_of_last_context_switch, &uptime, &used
);
_Timespec_Add_to( &ran, &used );
_Timestamp_Add_to( &ran, &used );
};
_Timespec_Divide( &ran, &total, &ival, &fval );
_Timestamp_Divide( &ran, &total, &ival, &fval );
/*
* Print the information
@@ -137,7 +137,9 @@ void rtems_cpu_usage_report_with_plugin(
(*print)( context,
"%3" PRId32 ".%06" PRId32 " %3" PRId32 ".%03" PRId32 "\n",
ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND,
_Timestamp_Get_seconds( &ran ),
_Timestamp_Get_nanoseconds( &ran ) /
TOD_NANOSECONDS_PER_MICROSECOND,
ival, fval
);
#else
@@ -159,8 +161,8 @@ void rtems_cpu_usage_report_with_plugin(
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
(*print)( context, "Time since last CPU Usage reset %" PRId32
".%06" PRId32 " seconds\n",
total.tv_sec,
total.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND
_Timestamp_Get_seconds( &total ),
_Timestamp_Get_nanoseconds( &total ) / TOD_NANOSECONDS_PER_MICROSECOND
);
#else
(*print)( context,
+3 -3
View File
@@ -16,6 +16,7 @@
#endif
#include <rtems.h>
#include <rtems/score/timestamp.h>
#include <stdlib.h>
#include <ctype.h>
@@ -28,8 +29,7 @@ static void CPU_usage_Per_thread_handler(
)
{
#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
@@ -40,7 +40,7 @@ static void CPU_usage_Per_thread_handler(
* External data that is shared by cpu usage code but not declared in .h files.
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
extern struct timespec CPU_usage_Uptime_at_last_reset;
extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
extern uint32_t CPU_usage_Ticks_at_last_reset;
#endif
+16 -8
View File
@@ -36,22 +36,30 @@ int clock_gettime(
if ( !tp )
rtems_set_errno_and_return_minus_one( EINVAL );
if ( clock_id == CLOCK_REALTIME )
if ( clock_id == CLOCK_REALTIME ) {
_TOD_Get(tp);
return 0;
}
#ifdef CLOCK_MONOTONIC
else if ( clock_id == CLOCK_MONOTONIC )
_TOD_Get_uptime(tp);
if ( clock_id == CLOCK_MONOTONIC ) {
_TOD_Get_uptime_as_timespec( tp );
return 0;
}
#endif
#ifdef _POSIX_CPUTIME
else if ( clock_id == CLOCK_PROCESS_CPUTIME )
_TOD_Get_uptime(tp);
if ( clock_id == CLOCK_PROCESS_CPUTIME ) {
_TOD_Get_uptime_as_timespec( tp );
return 0;
}
#endif
#ifdef _POSIX_THREAD_CPUTIME
else if ( clock_id == CLOCK_THREAD_CPUTIME )
if ( clock_id == CLOCK_THREAD_CPUTIME )
rtems_set_errno_and_return_minus_one( ENOSYS );
#endif
else
rtems_set_errno_and_return_minus_one( EINVAL );
rtems_set_errno_and_return_minus_one( EINVAL );
return 0;
}
+1
View File
@@ -31,6 +31,7 @@
#include <rtems/posix/config.h>
#include <rtems/posix/key.h>
#include <rtems/posix/time.h>
#include <rtems/score/timespec.h>
/*PAGE
*
+4 -2
View File
@@ -59,10 +59,12 @@ int timer_settime(
/* Convert absolute to relative time */
if (flags == TIMER_ABSTIME) {
struct timespec now;
_TOD_Get( &now );
/* Check for seconds in the past */
if ( _Timespec_Greater_than( &_TOD_Now, &normalize.it_value ) )
if ( _Timespec_Greater_than( &now, &normalize.it_value ) )
rtems_set_errno_and_return_minus_one( EINVAL );
_Timespec_Subtract( &_TOD_Now, &normalize.it_value, &normalize.it_value );
_Timespec_Subtract( &now, &normalize.it_value, &normalize.it_value );
}
/* If the function reaches this point, then it will be necessary to do
+13 -5
View File
@@ -70,7 +70,9 @@ extern "C" {
* statistics.
*/
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS)
typedef struct timespec rtems_rate_monotonic_period_time_t;
#include <rtems/score/timestamp.h>
typedef Timestamp_Control rtems_rate_monotonic_period_time_t;
#else
typedef uint32_t rtems_rate_monotonic_period_time_t;
#endif
@@ -382,8 +384,11 @@ void _Rate_monotonic_Timeout(
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
(_the_period)->Statistics.min_wall_time.tv_sec = 0x7fffffff; \
(_the_period)->Statistics.min_wall_time.tv_nsec = 0x7fffffff; \
_Timestamp_Set( \
&(_the_period)->Statistics.min_wall_time, \
0x7fffffff, \
0x7fffffff \
); \
} while (0)
#else
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period )
@@ -398,8 +403,11 @@ void _Rate_monotonic_Timeout(
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
(_the_period)->Statistics.min_cpu_time.tv_sec = 0x7fffffff; \
(_the_period)->Statistics.min_cpu_time.tv_nsec = 0x7fffffff; \
_Timestamp_Set( \
&(_the_period)->Statistics.min_cpu_time, \
0x7fffffff, \
0x7fffffff \
); \
} while (0)
#else
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period )
+1 -1
View File
@@ -33,6 +33,6 @@ rtems_status_code rtems_clock_get_seconds_since_epoch(
if ( !_TOD_Is_set )
return RTEMS_NOT_DEFINED;
*the_interval = _TOD_Seconds_since_epoch;
*the_interval = _TOD_Seconds_since_epoch();
return RTEMS_SUCCESSFUL;
}
+2 -1
View File
@@ -20,6 +20,7 @@
#include <rtems/rtems/clock.h>
#include <rtems/score/isr.h>
#include <rtems/score/thread.h>
#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -45,6 +46,6 @@ rtems_status_code rtems_clock_get_uptime(
if ( !uptime )
return RTEMS_INVALID_ADDRESS;
_TOD_Get_uptime( uptime );
_TOD_Get_uptime_as_timespec( uptime );
return RTEMS_SUCCESSFUL;
}
+5 -7
View File
@@ -65,14 +65,12 @@ rtems_status_code rtems_rate_monotonic_get_status(
if ( status->state == RATE_MONOTONIC_INACTIVE ) {
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
status->since_last_period.tv_sec = 0;
status->since_last_period.tv_nsec = 0;
_Timestamp_Set_to_zero( &status->since_last_period );
#else
status->since_last_period = 0;
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
status->executed_since_last_period.tv_sec = 0;
status->executed_since_last_period.tv_nsec = 0;
_Timestamp_Set_to_zero( &status->executed_since_last_period );
#else
status->executed_since_last_period = 0;
#endif
@@ -83,12 +81,12 @@ rtems_status_code rtems_rate_monotonic_get_status(
*/
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
struct timespec uptime;
Timestamp_Control uptime;
_TOD_Get_uptime( &uptime );
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
_Timespec_Subtract(
_Timestamp_Subtract(
&the_period->time_at_period,
&uptime,
&status->since_last_period
@@ -99,7 +97,7 @@ rtems_status_code rtems_rate_monotonic_get_status(
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
_Timespec_Subtract(
_Timestamp_Subtract(
&_Thread_Time_of_last_context_switch,
&uptime,
&status->executed_since_last_period
+15 -20
View File
@@ -22,11 +22,6 @@
#include <rtems/score/object.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
#include <rtems/score/timespec.h>
extern struct timespec _Thread_Time_of_last_context_switch;
#endif
void _Rate_monotonic_Update_statistics(
Rate_monotonic_Control *the_period
@@ -40,7 +35,7 @@ void _Rate_monotonic_Update_statistics(
#endif
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
struct timespec uptime;
Timestamp_Control uptime;
/*
* Obtain the current time since boot
@@ -60,7 +55,7 @@ void _Rate_monotonic_Update_statistics(
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
period_start = the_period->time_at_period;
_Timespec_Subtract( &period_start, &uptime, &since_last_period );
_Timestamp_Subtract( &period_start, &uptime, &since_last_period );
the_period->time_at_period = uptime;
#else
since_last_period = _Watchdog_Ticks_since_boot - the_period->time_at_period;
@@ -75,17 +70,17 @@ void _Rate_monotonic_Update_statistics(
used = _Thread_Executing->cpu_time_used;
/* partial period, cpu usage info reset while executing. Throw away */
if (_Timespec_Less_than( &used, &the_period->owner_executed_at_period))
if (_Timestamp_Less_than( &used, &the_period->owner_executed_at_period))
return;
/* How much time time since last context switch */
_Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
_Timestamp_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
/* executed += ran */
_Timespec_Add_to( &used, &ran );
_Timestamp_Add_to( &used, &ran );
/* executed = current cpu usage - value at start of period */
_Timespec_Subtract(
_Timestamp_Subtract(
&the_period->owner_executed_at_period,
&used,
&executed
@@ -112,12 +107,12 @@ void _Rate_monotonic_Update_statistics(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
_Timespec_Add_to( &stats->total_cpu_time, &executed );
_Timestamp_Add_to( &stats->total_cpu_time, &executed );
if ( _Timespec_Less_than( &executed, &stats->min_cpu_time ) )
if ( _Timestamp_Less_than( &executed, &stats->min_cpu_time ) )
stats->min_cpu_time = executed;
if ( _Timespec_Greater_than( &executed, &stats->max_cpu_time ) )
if ( _Timestamp_Greater_than( &executed, &stats->max_cpu_time ) )
stats->max_cpu_time = executed;
#else
stats->total_cpu_time += executed;
@@ -142,12 +137,12 @@ void _Rate_monotonic_Update_statistics(
if ( since_last_period > stats->max_wall_time )
stats->max_wall_time = since_last_period;
#else
_Timespec_Add_to( &stats->total_wall_time, &since_last_period );
_Timestamp_Add_to( &stats->total_wall_time, &since_last_period );
if ( _Timespec_Less_than( &since_last_period, &stats->min_wall_time ) )
if ( _Timestamp_Less_than( &since_last_period, &stats->min_wall_time ) )
stats->min_wall_time = since_last_period;
if ( _Timespec_Greater_than( &since_last_period, &stats->max_wall_time ) )
if ( _Timestamp_Greater_than( &since_last_period, &stats->max_wall_time ) )
stats->max_wall_time = since_last_period;
#endif
}
@@ -211,7 +206,7 @@ rtems_status_code rtems_rate_monotonic_period(
case RATE_MONOTONIC_INACTIVE: {
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
struct timespec uptime;
Timestamp_Control uptime;
#endif
/*
@@ -244,7 +239,7 @@ rtems_status_code rtems_rate_monotonic_period(
_Thread_Executing->cpu_time_used;
/* How much time time since last context switch */
_Timespec_Subtract(
_Timestamp_Subtract(
&_Thread_Time_of_last_context_switch,
&uptime,
&ran
@@ -254,7 +249,7 @@ rtems_status_code rtems_rate_monotonic_period(
*
* the_period->owner_executed_at_period += ran
*/
_Timespec_Add_to( &the_period->owner_executed_at_period, &ran );
_Timestamp_Add_to( &the_period->owner_executed_at_period, &ran );
}
#else
the_period->owner_executed_at_period =
+24 -25
View File
@@ -24,7 +24,7 @@
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
#include <rtems/score/timespec.h>
#include <rtems/score/timestamp.h>
/* We print to 1/10's of milliseconds */
#define NANOSECONDS_DIVIDER 1000
@@ -149,23 +149,22 @@ ididididid NNNN ccccc mmmmmm X
*/
{
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
struct timespec cpu_average;
Timestamp_Control cpu_average;
Timestamp_Control *min_cpu = &the_stats.min_cpu_time;
Timestamp_Control *max_cpu = &the_stats.max_cpu_time;
Timestamp_Control *total_cpu = &the_stats.total_cpu_time;
_Timespec_Divide_by_integer(
&the_stats.total_cpu_time,
the_stats.count,
&cpu_average
);
_Timestamp_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
(*print)( context,
"%" PRId32 "." NANOSECONDS_FMT "/" /* min cpu time */
"%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */
"%" PRId32 "." NANOSECONDS_FMT " ", /* avg cpu time */
the_stats.min_cpu_time.tv_sec,
the_stats.min_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
the_stats.max_cpu_time.tv_sec,
the_stats.max_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
cpu_average.tv_sec,
cpu_average.tv_nsec / NANOSECONDS_DIVIDER
_Timestamp_Get_seconds( min_cpu ),
_Timestamp_Get_nanoseconds( min_cpu ) / NANOSECONDS_DIVIDER,
_Timestamp_Get_seconds( max_cpu ),
_Timestamp_Get_nanoseconds( max_cpu ) / NANOSECONDS_DIVIDER,
_Timestamp_Get_seconds( &cpu_average ),
_Timestamp_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_cpu, fval_cpu;
@@ -186,22 +185,22 @@ ididididid NNNN ccccc mmmmmm X
*/
{
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
struct timespec wall_average;
_Timespec_Divide_by_integer(
&the_stats.total_wall_time,
the_stats.count,
&wall_average
);
Timestamp_Control wall_average;
Timestamp_Control *min_wall = &the_stats.min_wall_time;
Timestamp_Control *max_wall = &the_stats.max_wall_time;
Timestamp_Control *total_wall = &the_stats.total_wall_time;
_Timestamp_Divide_by_integer(total_wall, the_stats.count, &wall_average);
(*print)( context,
"%" PRId32 "." NANOSECONDS_FMT "/" /* min wall time */
"%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */
"%" PRId32 "." NANOSECONDS_FMT "\n", /* avg wall time */
the_stats.min_wall_time.tv_sec,
the_stats.min_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
the_stats.max_wall_time.tv_sec,
the_stats.max_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
wall_average.tv_sec,
wall_average.tv_nsec / NANOSECONDS_DIVIDER
_Timestamp_Get_seconds( min_wall ),
_Timestamp_Get_nanoseconds( min_wall ) / NANOSECONDS_DIVIDER,
_Timestamp_Get_seconds( max_wall ),
_Timestamp_Get_nanoseconds( max_wall ) / NANOSECONDS_DIVIDER,
_Timestamp_Get_seconds( &wall_average ),
_Timestamp_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_wall, fval_wall;
+2 -2
View File
@@ -67,7 +67,7 @@ rtems_status_code rtems_task_wake_when(
seconds = _TOD_To_seconds( time_buffer );
if ( seconds <= _TOD_Seconds_since_epoch )
if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
_Thread_Disable_dispatch();
@@ -80,7 +80,7 @@ rtems_status_code rtems_task_wake_when(
);
_Watchdog_Insert_seconds(
&_Thread_Executing->Timer,
seconds - _TOD_Seconds_since_epoch
seconds - _TOD_Seconds_since_epoch()
);
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
+2 -2
View File
@@ -63,7 +63,7 @@ rtems_status_code rtems_timer_fire_when(
return RTEMS_INVALID_ADDRESS;
seconds = _TOD_To_seconds( wall_time );
if ( seconds <= _TOD_Seconds_since_epoch )
if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
the_timer = _Timer_Get( id, &location );
@@ -75,7 +75,7 @@ rtems_status_code rtems_timer_fire_when(
_Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
_Watchdog_Insert_seconds(
&the_timer->Ticker,
seconds - _TOD_Seconds_since_epoch
seconds - _TOD_Seconds_since_epoch()
);
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
+2 -2
View File
@@ -189,7 +189,7 @@ static void _Timer_Server_process_seconds_chain(
* of Day (TOD) has not been set backwards. If it has then
* we want to adjust the _Timer_Seconds_chain to indicate this.
*/
snapshot = _TOD_Seconds_since_epoch;
snapshot = _TOD_Seconds_since_epoch();
if ( snapshot > _Timer_Server_seconds_last_time ) {
/*
* This path is for normal forward movement and cases where the
@@ -232,7 +232,7 @@ Thread _Timer_Server_body(
* the server was initiated.
*/
_Timer_Server_ticks_last_time = _Watchdog_Ticks_since_boot;
_Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch;
_Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch();
/*
* Insert the timers that were inserted before we got to run.
+2 -2
View File
@@ -67,7 +67,7 @@ rtems_status_code rtems_timer_server_fire_when(
return RTEMS_INVALID_CLOCK;
seconds = _TOD_To_seconds( wall_time );
if ( seconds <= _TOD_Seconds_since_epoch )
if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
the_timer = _Timer_Get( id, &location );
@@ -77,7 +77,7 @@ rtems_status_code rtems_timer_server_fire_when(
(void) _Watchdog_Remove( &the_timer->Ticker );
the_timer->the_class = TIMER_TIME_OF_DAY_ON_TASK;
_Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch;
the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch();
/*
* _Timer_Server_schedule_operation != NULL because we checked that
+5 -5
View File
@@ -29,10 +29,10 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \
include/rtems/score/stack.h include/rtems/score/states.h \
include/rtems/score/sysstate.h include/rtems/score/thread.h \
include/rtems/score/threadq.h include/rtems/score/threadsync.h \
include/rtems/score/timespec.h include/rtems/score/tod.h \
include/rtems/score/tqdata.h include/rtems/score/userext.h \
include/rtems/score/watchdog.h include/rtems/score/wkspace.h \
include/rtems/score/cpuopts.h
include/rtems/score/timespec.h include/rtems/score/timestamp.h \
include/rtems/score/tod.h include/rtems/score/tqdata.h \
include/rtems/score/userext.h include/rtems/score/watchdog.h \
include/rtems/score/wkspace.h include/rtems/score/cpuopts.h
if HAS_MP
# We only build multiprocessing related files if HAS_MP was defined
@@ -169,7 +169,7 @@ libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
## TOD_C_FILES
libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
src/coretodgetuptime.c src/coretodtickle.c
src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c
## WATCHDOG_C_FILES
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
+4 -2
View File
@@ -36,6 +36,8 @@ extern "C" {
* resolution.
*/
#ifndef __RTEMS_USE_TICKS_CPU_USAGE_STATISTICS__
#include <rtems/score/timestamp.h>
/**
* This macro enables the nanosecond accurate statistics
*
@@ -44,7 +46,7 @@ extern "C" {
*/
#define RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
typedef struct timespec rtems_thread_cpu_usage_t;
typedef Timestamp_Control rtems_thread_cpu_usage_t;
#else
typedef uint32_t rtems_thread_cpu_usage_t;
@@ -500,7 +502,7 @@ SCORE_EXTERN struct _reent **_Thread_libc_reent;
* system initialization and does not need to be known outside this
* file.
*/
SCORE_EXTERN struct timespec _Thread_Time_of_last_context_switch;
SCORE_EXTERN Timestamp_Control _Thread_Time_of_last_context_switch;
#endif
/**
File diff suppressed because it is too large. Load diff
+16 -4
View File
@@ -23,7 +23,7 @@
extern "C" {
#endif
#include <rtems/score/object.h>
#include <rtems/score/timestamp.h>
#include <time.h>
/** @defgroup ScoreTODConstants TOD Constants
@@ -134,18 +134,19 @@ SCORE_EXTERN bool _TOD_Is_set;
/** @brief Current Time of Day (Timespec)
* The following contains the current time of day.
*/
SCORE_EXTERN struct timespec _TOD_Now;
SCORE_EXTERN Timestamp_Control _TOD_Now;
/** @brief Current Time of Day (Timespec)
* The following contains the running uptime.
*/
SCORE_EXTERN struct timespec _TOD_Uptime;
SCORE_EXTERN Timestamp_Control _TOD_Uptime;
/** @brief Seconds Since RTEMS Epoch
* The following contains the number of seconds from 00:00:00
* January 1, TOD_BASE_YEAR until the current time of day.
*/
#define _TOD_Seconds_since_epoch (_TOD_Now.tv_sec)
#define _TOD_Seconds_since_epoch() \
_Timestamp_Get_seconds(&_TOD_Now)
/** @brief Microseconds per Clock Tick
*
@@ -189,6 +190,17 @@ void _TOD_Get(
* @param[in] time is a pointer to the uptime to be returned
*/
void _TOD_Get_uptime(
Timestamp_Control *time
);
/** @brief _TOD_Get_uptime_as_timespec
*
* This routine returns the system uptime with potential accuracy
* to the nanosecond.
*
* @param[in] time is a pointer to the uptime to be returned
*/
void _TOD_Get_uptime_as_timespec(
struct timespec *time
);
+4
View File
@@ -139,6 +139,10 @@ $(PROJECT_INCLUDE)/rtems/score/timespec.h: include/rtems/score/timespec.h $(PROJ
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timespec.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timespec.h
$(PROJECT_INCLUDE)/rtems/score/timestamp.h: include/rtems/score/timestamp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp.h
$(PROJECT_INCLUDE)/rtems/score/tod.h: include/rtems/score/tod.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tod.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tod.h
+2 -4
View File
@@ -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;
+13 -10
View File
@@ -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 );
}
+14 -12
View File
@@ -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 );
}
@@ -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 );
}
+10 -7
View File
@@ -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();
+7 -8
View File
@@ -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--;
+8 -4
View File
@@ -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
+1 -2
View File
@@ -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