summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coretodset.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-02-18 08:36:26 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-04 13:36:10 +0100
commit03b900d3ed120ea919ea3eded7edbece3488cff3 (patch)
tree182781fc14fe15fd67caeb80e46f1c58495839c2 /cpukit/score/src/coretodset.c
parentscore: Distribute clock tick to all online CPUs (diff)
downloadrtems-03b900d3ed120ea919ea3eded7edbece3488cff3.tar.bz2
score: Replace watchdog handler implementation
Use a red-black tree instead of delta chains. Close #2344. Update #2554. Update #2555. Close #2606.
Diffstat (limited to 'cpukit/score/src/coretodset.c')
-rw-r--r--cpukit/score/src/coretodset.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index 3230179414..b2efc07115 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -26,30 +26,26 @@ void _TOD_Set_with_timestamp(
const Timestamp_Control *tod_as_timestamp
)
{
- struct timespec ts;
- uint32_t nanoseconds;
- Watchdog_Interval seconds_next;
- Watchdog_Interval seconds_now;
- Watchdog_Header *header;
+ struct timespec tod_as_timespec;
+ uint64_t tod_as_ticks;
+ uint32_t cpu_count;
+ uint32_t cpu_index;
- _Timestamp_To_timespec( tod_as_timestamp, &ts );
- nanoseconds = ts.tv_nsec;
- seconds_next = ts.tv_sec;
+ _Timestamp_To_timespec( tod_as_timestamp, &tod_as_timespec );
_Thread_Disable_dispatch();
- seconds_now = _TOD_Seconds_since_epoch();
+ _Timecounter_Set_clock( &tod_as_timespec );
- _Timecounter_Set_clock( &ts );
+ tod_as_ticks = _Watchdog_Ticks_from_timespec( &tod_as_timespec );
+ cpu_count = _SMP_Get_processor_count();
- header = &_Watchdog_Seconds_header;
+ for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
+ Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
- if ( seconds_next < seconds_now )
- _Watchdog_Adjust_backward( header, seconds_now - seconds_next );
- else
- _Watchdog_Adjust_forward( header, seconds_next - seconds_now );
+ _Watchdog_Per_CPU_tickle_absolute( cpu, tod_as_ticks );
+ }
- _TOD.seconds_trigger = nanoseconds;
_TOD.is_set = true;
_Thread_Enable_dispatch();