This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: ecos idle function--A correction and clarification.
- From: Milind Kopikare <milindkopi at yahoo dot com>
- To: Andrew Lunn <andrew dot lunn at ascom dot ch>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Mon, 20 Jan 2003 16:12:41 -0800 (PST)
- Subject: Re: [ECOS] ecos idle function--A correction and clarification.
Hi Andrew,
I realised why the new thread was not getting
spawned off. This was because I was calling your code
even before the scheduler had been intialised.
Basically I was calling your code in the
cyg_user_start() function which is called even before
cyg_scheduler_start().
I apologise if anyone had tomspend time on solving
my question.
But as a sequel, I would like to know why
sometimes, the idle_loops can turn out to be more than
the calibration. in other words, when we calibrate, we
only allow the idle_thread_main function to run with
the highest priority. Hence whatever value is recorded
for those 100ms by idle_thread_loops should be the
maximum possible. But when the code runs, there are
instances when the idle_thread_loops has a higher
value than the previously calibrated value. You also
have a provision in your code to check for this
condition. I am curious as to why this condition could
crop up.
Thanks in advance,
Milind
--- Milind Kopikare <milindkopi@yahoo.com> wrote:
> Hi Andrew,
> I can break the problem into the following
> point.
> If I start the create idle_thread_main() with a
> priority 1, and then run through the code using the
> debugger, the code dosent start the new thread. I am
> using your code. creating the thread, resuming it
> etc. The current thread has priority 31 and hence
> shouldn't interfere with the starting of this new
> thread. I even tried suspending the current thread,
> hoping that atleast now it will jump to the
> idle_thread_main() function. But it dosen't. Here's
> a
> brief part of the code.
>
> ///////////
> cyg_thread_create(1,
> idle_thread_main,
> 0,
> "Calibration idle thread",
> idle_stack,
> sizeof(idle_stack),
> &idleH,
> &thread);
>
>
cyg_clock_to_counter(cyg_real_time_clock(),&counter);
>
>
cyg_alarm_create(counter,alarm_func,(cyg_addrword_t)idleH,&alarmH,&alarm_s);
>
>
>
cyg_alarm_initialize(alarmH,cyg_current_time()+10,0);
> cyg_alarm_enable(alarmH);
>
> idle_loops_start = idle_thread_loops;
>
> /* Dont be decieved, remember this is a
> multithreaded system ! */
> old_priority =
> cyg_thread_get_priority(cyg_thread_self());
> cyg_thread_set_priority(cyg_thread_self(),2);
> cyg_thread_resume(idleH);
>
>
> *calibration = idle_thread_loops -
> idle_loops_start;
> cyg_alarm_delete(alarmH);
> cyg_thread_kill(idleH);
> cyg_thread_delete(idleH);
>
>
cyg_thread_set_priority(cyg_thread_self(),old_priority);
>
> /////////////////
>
> The code simply jumps from cyg_thread_resume to the
> next line, without jumping into idle_thread_main. I
> know this also because I had set break points in
> idle_thread_main().
>
> Would really appericiate your feedback.
>
> Thanks,
> Milind
>
>
>
> --- Andrew Lunn <andrew.lunn@ascom.ch> wrote:
> > On Thu, Jan 16, 2003 at 12:14:40PM -0800, Milind
> > Kopikare wrote:
> > > Hi,
> > > this question has been posted before but I
> > didn't
> > > quite get the answer.
> > > In eCos, Andrew Lunn's code should work if
> in
> > idle
> > > time we shift to the idle_thread_main function
> in
> > > thread.cxx. But, whenever the processor is
> idling,
> > the
> > > code dosent jump there. For want of other tasks
> to
> > do,
> > > the processor hangs.
> >
> > Could you explain this is more detail please.
> > Something sounds very
> > wrong here.
> >
> > Andrew
> >
> > --
> > Before posting, please read the FAQ:
> > http://sources.redhat.com/fom/ecos
> > and search the list archive:
> > http://sources.redhat.com/ml/ecos-discuss
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
>
> --
> Before posting, please read the FAQ:
> http://sources.redhat.com/fom/ecos
> and search the list archive:
> http://sources.redhat.com/ml/ecos-discuss
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss