[ECOS] On Alarms...

Jonathan Larmour jifl@eCosCentric.com
Thu Jan 23 02:31:00 GMT 2003


Milind Kopikare wrote:
> Hi, 
>    A few questions on alarms.
>   
> 1> Are Alarms like interrupts? If so, what's the
> priority? I've been using Alarms and they seem to stop
> even the highest of priority tasks. But just curios on
> how it's implemented internally. Is there a more
> comprehensive doc to read up on this.

Alarm's are called as a result of the kernel clock interrupt. As David 
says, this results in the alarm handlers being called in a DSR context, in 
this case from the clock DSR.

> 2> I was trying to toggle between starting a thread
> and suspending it using an Alarm. 
> void alarm_func(){
>    if (thread is suspended)
>        cyg_thread_resume
>    else 
>        cyg_thread_suspend
> }
> But if I keep the Alarm resolution too small, say the
> Alarm triggers every 2 ticks (2*10ms), the thread does
> not resume. It's as if the scheduler is taking more
> than 2 ms to start the thread. Any insight into what's
> wrong? Ofcourse, if I give the ALARM resolution as
> 100ms (10ticks), the thread toggles allright.

Just on the off-chance, is the thread doing any diagnostic output, 
especially via GDB? If so, interrupts will be disabled while the output is 
performed which could easily be up to 2 ticks. Diagnostic output shouldn't 
be used for "real" applications - use proper interrupt-driven drivers instead.

> 3. Can we have more than one periodic Alarm? I mean if
> I have two alarms, and both trigger every 100ms, only
> the alarm enabled seems to be activated. The first one
> dosent seem to work. Any insight?

That should work. If it doesn't there's a problem. Do you have a concise 
test case?

Jifl
-- 
eCosCentric       http://www.eCosCentric.com/       <info@eCosCentric.com>
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


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



More information about the Ecos-discuss mailing list