diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-02-18 08:36:26 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-04 13:36:10 +0100 |
commit | 03b900d3ed120ea919ea3eded7edbece3488cff3 (patch) | |
tree | 182781fc14fe15fd67caeb80e46f1c58495839c2 /cpukit/posix/src/timergettime.c | |
parent | score: Distribute clock tick to all online CPUs (diff) | |
download | rtems-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/posix/src/timergettime.c')
-rw-r--r-- | cpukit/posix/src/timergettime.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c index f065cc927c..7f0015bf5e 100644 --- a/cpukit/posix/src/timergettime.c +++ b/cpukit/posix/src/timergettime.c @@ -42,31 +42,32 @@ int timer_gettime( { POSIX_Timer_Control *ptimer; Objects_Locations location; - struct timespec current_time; - Watchdog_Interval left; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu; + uint64_t now; + uint32_t remaining; if ( !value ) rtems_set_errno_and_return_minus_one( EINVAL ); - /* Reads the current time */ - _TOD_Get_as_timespec( ¤t_time ); - - ptimer = _POSIX_Timer_Get( timerid, &location ); + ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context ); switch ( location ) { case OBJECTS_LOCAL: - /* Calculates the time left before the timer finishes */ - - left = - (ptimer->Timer.start_time + ptimer->Timer.initial) - /* expire */ - _Watchdog_Ticks_since_boot; /* now */ + cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context ); + now = cpu->Watchdog.ticks; - _Timespec_From_ticks( left, &value->it_value ); + if ( now < ptimer->Timer.expire ) { + remaining = (uint32_t) ( ptimer->Timer.expire - now ); + } else { + remaining = 0; + } - value->it_interval = ptimer->timer_data.it_interval; + _Timespec_From_ticks( remaining, &value->it_value ); + value->it_interval = ptimer->timer_data.it_interval; - _Objects_Put( &ptimer->Object ); + _POSIX_Timer_Release( cpu, &lock_context ); return 0; #if defined(RTEMS_MULTIPROCESSING) |