diff options
author | Kuan-Hsun Chen <c0066c@gmail.com> | 2017-01-27 23:15:50 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-30 07:53:13 +0100 |
commit | 0794197f729f5ee9551dc7b2e14867f394cbc327 (patch) | |
tree | 75ead135c567f4956396c10a030888fa156ffdba /cpukit/rtems/src/ratemontimeout.c | |
parent | score: Clarify _Heap_Extend() (diff) | |
download | rtems-0794197f729f5ee9551dc7b2e14867f394cbc327.tar.bz2 |
rtems: Fix _Rate_monotonic_Renew_deadline()
Prepare a precondition to prevent the potential integer overflow.
Remove one redundant parameter in _Rate_monotonic_Renew_deadline().
sptests/sprmsched02: Create
A test case for checking the overflow condition of postponed_jobs
in rtems_rate_monotonic_period_status.
Update #2885.
Diffstat (limited to 'cpukit/rtems/src/ratemontimeout.c')
-rw-r--r-- | cpukit/rtems/src/ratemontimeout.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c index bcc4ccfbf8..5a838fd916 100644 --- a/cpukit/rtems/src/ratemontimeout.c +++ b/cpukit/rtems/src/ratemontimeout.c @@ -9,7 +9,7 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * COPYRIGHT (c) 2016 Kuan-Hsun Chen. + * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -24,13 +24,16 @@ static void _Rate_monotonic_Renew_deadline( Rate_monotonic_Control *the_period, - Thread_Control *owner, ISR_lock_Context *lock_context ) { uint64_t deadline; - ++the_period->postponed_jobs; + /* stay at 0xffffffff if postponed_jobs is going to overflow */ + if ( the_period->postponed_jobs != UINT32_MAX ) { + ++the_period->postponed_jobs; + } + the_period->state = RATE_MONOTONIC_EXPIRED; deadline = _Watchdog_Per_CPU_insert_relative( @@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog ) _Thread_Unblock( owner ); } } else { - _Rate_monotonic_Renew_deadline( the_period, owner, &lock_context ); + _Rate_monotonic_Renew_deadline( the_period, &lock_context ); } } |