This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

minor simplification in mlqueue.cxx (schedule)


Won't it be clearer, if following code fragment from "Cyg_Scheduler_Implementation::schedule(void)" in mlqueue.cxx

-----------------------------------------------------------------
// If the current thread is still runnable, return it to pending
// state so that it can be considered alongside any other threads
// for execution.
if( current->get_state() == Cyg_Thread::RUNNING )
{
    current->cpu = CYG_KERNEL_CPU_NONE;
    pending[current->priority]++;
    pending_map |= (1<<current->priority);
}
else
{
    // Otherwise, ensure that the thread is no longer marked as
    // running.
    current->cpu = CYG_KERNEL_CPU_NONE;
}
-------------------------------------------------------------------

is simplified to

-----------------------------------------------------------------
// If the current thread is still runnable, return it to pending
// state so that it can be considered alongside any other threads
// for execution.
if( current->get_state() == Cyg_Thread::RUNNING )
{
    pending[current->priority]++;
    pending_map |= (1<<current->priority);
}

// ensure that the thread is no longer marked as running.
current->cpu = CYG_KERNEL_CPU_NONE;
-------------------------------------------------------------------

since setting the current cpu to NONE is common action for both - then and else.

is there some reason that things have been kept the way they are?

---
sandeep


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]