This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: minor simplification in mlqueue.cxx (schedule)
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: sandeep <shimple0 at yahoo dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: 24 Nov 2004 09:48:00 +0000
- Subject: Re: [ECOS] minor simplification in mlqueue.cxx (schedule)
- References: <419F38CF.20404@yahoo.com>
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