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]

Re: minor simplification in mlqueue.cxx (schedule)


sandeep <shimple0@yahoo.com> writes:

> 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?

I suspect this is left over from debugging. At one point it was useful
to insert debug code into each branch of the test. The code was left
as it is in case we needed to do that again.


-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


-- 
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]