Stewart, >>> Stewart, >>> >>> I appreciate your suggestion to eliminate the while loop. >>> What about initializing major_frame and schedule[0].runtime to >>> DEFAULT_TIMESLICE at a653sched_init() and use them until the real >>> parameters are set as below to eliminate the if branch? >> >> It would make the scheduling code cleaner, but since you asked Stew I'll > defer to him. > > It feels odd to index schedule[0] when num_schedule_entries may be zero... > But since it's a fixed size array and element 0 is guaranteed to exist I don't > have a strong preference. >
Thanks for your feedback. If you don't have a strong preference, let me write a v3 patch with the following change. /* Switch to next major frame directly eliminating the use of loop */ if ( now >= sched_priv->next_major_frame ) { s_time_t major_frame = sched_priv->major_frame; s_time_t remainder = (now - sched_priv->next_major_frame) % major_frame; /* major_frame and schedule[0].runtime contain DEFAULT_TIMESLICE * if num_schedule_entries is zero. */ sched_priv->sched_index = 0; sched_priv->next_major_frame = now - remainder + major_frame; sched_priv->next_switch_time = now - remainder + sched_priv->schedule[0].runtime; } /* Switch minor frame */ while ( (now >= sched_priv->next_switch_time) && I'll also include the "Fixes" tag you mentioned in the previous comment. Fixes: 22787f2e107c ("ARINC 653 scheduler") Thanks, Anderson