diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-27 22:07:56 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-02 07:46:16 +0200 |
commit | 1ef8e4a8e93a848e2a68f37e029039300f1c936b (patch) | |
tree | 1a592f827f25a7803f4c70520efd8ce514a523e6 /cpukit/score/src | |
parent | 3888771772a57b4c924e1987e603e7a1b957e07c (diff) |
score: Avoid Giant lock for set time of day
Update #2555.
Update #2630.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/coretodadjust.c | 22 | ||||
-rw-r--r-- | cpukit/score/src/coretodset.c | 14 | ||||
-rw-r--r-- | cpukit/score/src/kern_tc.c | 47 |
3 files changed, 42 insertions, 41 deletions
diff --git a/cpukit/score/src/coretodadjust.c b/cpukit/score/src/coretodadjust.c index 51c10ec849..5996565e5c 100644 --- a/cpukit/score/src/coretodadjust.c +++ b/cpukit/score/src/coretodadjust.c @@ -18,14 +18,14 @@ #include "config.h" #endif -#include <rtems/score/threaddispatch.h> #include <rtems/score/todimpl.h> void _TOD_Adjust( - const Timestamp_Control delta + const Timestamp_Control *delta ) { Timestamp_Control tod; + ISR_lock_Context lock_context; /* * Currently, RTEMS does the adjustment in one movement. @@ -35,16 +35,10 @@ void _TOD_Adjust( * adjustment. */ - /* - * This prevents context switches while we are adjusting the TOD - */ - _Thread_Disable_dispatch(); - - _TOD_Get( &tod ); - - _Timestamp_Add_to( &tod, &delta ); - - _TOD_Set( &tod ); - - _Thread_Enable_dispatch(); + _TOD_Lock(); + _TOD_Acquire( &lock_context ); + _TOD_Get( &tod ); + _Timestamp_Add_to( &tod, delta ); + _TOD_Set( &tod, &lock_context ); + _TOD_Unlock(); } diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c index e11f47c904..f1d2e36eb0 100644 --- a/cpukit/score/src/coretodset.c +++ b/cpukit/score/src/coretodset.c @@ -19,11 +19,12 @@ #endif #include <rtems/score/todimpl.h> -#include <rtems/score/threaddispatch.h> +#include <rtems/score/assert.h> #include <rtems/score/watchdogimpl.h> void _TOD_Set( - const Timestamp_Control *tod_as_timestamp + const Timestamp_Control *tod_as_timestamp, + ISR_lock_Context *lock_context ) { struct timespec tod_as_timespec; @@ -31,12 +32,11 @@ void _TOD_Set( uint32_t cpu_count; uint32_t cpu_index; - _Timestamp_To_timespec( tod_as_timestamp, &tod_as_timespec ); - - _Thread_Disable_dispatch(); + _Assert( _API_Mutex_Is_owner( _Once_Mutex ) ); - _Timecounter_Set_clock( &tod_as_timespec ); + _Timecounter_Set_clock( tod_as_timestamp, lock_context ); + _Timestamp_To_timespec( tod_as_timestamp, &tod_as_timespec ); tod_as_ticks = _Watchdog_Ticks_from_timespec( &tod_as_timespec ); cpu_count = _SMP_Get_processor_count(); @@ -47,6 +47,4 @@ void _TOD_Set( } _TOD.is_set = true; - - _Thread_Enable_dispatch(); } diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c index b9ea608d9d..03d09971f2 100644 --- a/cpukit/score/src/kern_tc.c +++ b/cpukit/score/src/kern_tc.c @@ -33,6 +33,7 @@ #define time_uptime _Timecounter_Time_uptime #define boottimebin _Timecounter_Boottimebin #include <rtems/score/timecounterimpl.h> +#include <rtems/score/smp.h> #include <rtems/score/todimpl.h> #include <rtems/score/watchdogimpl.h> #endif /* __rtems__ */ @@ -215,6 +216,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static void tc_windup(void); #ifndef __rtems__ static void cpu_tick_calibrate(int); +#else /* __rtems__ */ +static void _Timecounter_Windup(ISR_lock_Context *lock_context); #endif /* __rtems__ */ void dtrace_getnanotime(struct timespec *tsp); @@ -1344,12 +1347,12 @@ tc_getfrequency(void) * when we booted. * XXX: not locked. */ -#ifndef __rtems__ void +#ifndef __rtems__ tc_setclock(struct timespec *ts) #else /* __rtems__ */ -void -_Timecounter_Set_clock(const struct timespec *ts) +_Timecounter_Set_clock(const struct bintime *_bt, + ISR_lock_Context *lock_context) #endif /* __rtems__ */ { #ifndef __rtems__ @@ -1360,19 +1363,19 @@ _Timecounter_Set_clock(const struct timespec *ts) #ifndef __rtems__ cpu_tick_calibrate(1); nanotime(&tbef); -#endif /* __rtems__ */ timespec2bintime(ts, &bt); +#else /* __rtems__ */ + bt = *_bt; +#endif /* __rtems__ */ binuptime(&bt2); bintime_sub(&bt, &bt2); bintime_add(&bt2, &boottimebin); boottimebin = bt; #ifndef __rtems__ bintime2timeval(&bt, &boottime); -#endif /* __rtems__ */ /* XXX fiddle all the little crinkly bits around the fiords... */ tc_windup(); -#ifndef __rtems__ nanotime(&taft); if (timestepwarnings) { log(LOG_INFO, @@ -1382,6 +1385,8 @@ _Timecounter_Set_clock(const struct timespec *ts) (intmax_t)ts->tv_sec, ts->tv_nsec); } cpu_tick_calibrate(1); +#else /* __rtems__ */ + _Timecounter_Windup(lock_context); #endif /* __rtems__ */ } @@ -1392,6 +1397,17 @@ _Timecounter_Set_clock(const struct timespec *ts) */ static void tc_windup(void) +#ifdef __rtems__ +{ + ISR_lock_Context lock_context; + + _Timecounter_Acquire(&lock_context); + _Timecounter_Windup(&lock_context); +} + +static void +_Timecounter_Windup(ISR_lock_Context *lock_context) +#endif /* __rtems__ */ { struct bintime bt; struct timehands *th, *tho; @@ -1399,11 +1415,6 @@ tc_windup(void) uint32_t delta, ncount, ogen; int i; time_t t; -#ifdef __rtems__ - ISR_lock_Context lock_context; - - _Timecounter_Acquire(&lock_context); -#endif /* __rtems__ */ /* * Make the next timehands a copy of the current one, but do not @@ -1565,7 +1576,7 @@ tc_windup(void) timekeep_push_vdso(); #endif /* __rtems__ */ #ifdef __rtems__ - _Timecounter_Release(&lock_context); + _Timecounter_Release(lock_context); #endif /* __rtems__ */ } @@ -1978,23 +1989,21 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; + tc_windup(); +} #else /* __rtems__ */ -#include <rtems/score/smp.h> void _Timecounter_Tick(void) { Per_CPU_Control *cpu_self = _Per_CPU_Get(); if (_Per_CPU_Is_boot_processor(cpu_self)) { -#endif /* __rtems__ */ - tc_windup(); -#ifdef __rtems__ - }; + tc_windup(); + } _Watchdog_Tick(cpu_self); -#endif /* __rtems__ */ } -#ifdef __rtems__ + void _Timecounter_Tick_simple(uint32_t delta, uint32_t offset, ISR_lock_Context *lock_context) |