[RTEMS Project] #2173: Potential integer overflow problem in EDF scheduler
RTEMS trac
trac at rtems.org
Tue Jan 31 09:18:55 UTC 2017
#2173: Potential integer overflow problem in EDF scheduler
-----------------------------+----------------------------
Reporter: sebastian.huber | Owner: joel.sherrill
Type: defect | Status: closed
Priority: normal | Milestone: 4.12
Component: cpukit | Version: 4.11
Severity: normal | Resolution: fixed
Keywords: |
-----------------------------+----------------------------
Changes (by sebastian.huber):
* status: reopened => closed
* resolution: => fixed
* milestone: 4.11.2 => 4.12
Old description:
> On 2014-03-21 14:46, Gedare Bloom wrote:> On Fri, Mar 21, 2014 at 9:43
> AM, Sebastian Huber
> > <sebastian.huber at embedded-brains.de> wrote:
> [...]
> >> >I have another question regarding the EDF scheduler. Does this work
> in case
> >> >_Watchdog_Ticks_since_boot overflows?
> >> >
> > No. For this, I think we need to use "deadline folding" which is just
> > modulo arithmetic.
> >
> >> >void _Scheduler_EDF_Release_job(
> >> > Thread_Control *the_thread,
> >> > uint32_t deadline
> >> >)
> >> >{
> >> > Priority_Control new_priority;
> >> >
> >> > if (deadline) {
> >> > /* Initializing or shifting deadline. */
> >> > new_priority = (_Watchdog_Ticks_since_boot + deadline)
> >> > & ~SCHEDULER_EDF_PRIO_MSB;
> >> > }
> >> > else {
> >> > /* Switch back to background priority. */
> >> > new_priority = the_thread->Start.initial_priority;
> >> > }
> >> >
> >> > the_thread->real_priority = new_priority;
> >> > _Thread_Change_priority(the_thread, new_priority, true);
> >> >
> >> >}
>
> _Watchdog_Ticks_since_boot us uint32_t and overflows after 49 days with a
> one millisecond clock tick.
New description:
On 2014-03-21 14:46, Gedare Bloom wrote:> On Fri, Mar 21, 2014 at 9:43 AM,
Sebastian Huber
> <sebastian.huber at embedded-brains.de> wrote:
[...]
>> >I have another question regarding the EDF scheduler. Does this work
in case
>> >_Watchdog_Ticks_since_boot overflows?
>> >
> No. For this, I think we need to use "deadline folding" which is just
> modulo arithmetic.
>
>> >void _Scheduler_EDF_Release_job(
>> > Thread_Control *the_thread,
>> > uint32_t deadline
>> >)
>> >{
>> > Priority_Control new_priority;
>> >
>> > if (deadline) {
>> > /* Initializing or shifting deadline. */
>> > new_priority = (_Watchdog_Ticks_since_boot + deadline)
>> > & ~SCHEDULER_EDF_PRIO_MSB;
>> > }
>> > else {
>> > /* Switch back to background priority. */
>> > new_priority = the_thread->Start.initial_priority;
>> > }
>> >
>> > the_thread->real_priority = new_priority;
>> > _Thread_Change_priority(the_thread, new_priority, true);
>> >
>> >}
_Watchdog_Ticks_since_boot us uint32_t and overflows after 49 days with a
one millisecond clock tick.
--
--
Ticket URL: <http://devel.rtems.org/ticket/2173#comment:13>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list