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: how can I create real time clock interrupt? (how Clock interrupt handled?)


Thanks a lot Andrew.

I am confused about whether there will be any recursive call or not?

When in step (3). call_pending_DSRs() [supplied in assembly code] is called
*But "call_pending_DSRs()" is only called in "unlock_inner()", and
"unlock_inner()" is also
called:

from **Cyg_RealTimeClock::dsr()**

rtc->tick( count ) [ in Cyg_RealTimeClock::dsr()] <--
Cyg_Scheduler::unlock() [in Cyg_Counter::tick()] <-- unlock_inner(0)[called
in Cyg_Scheduler::unlock()]

so seems it goes back to unlock_inner() again, I just can't figure out what
is going on here? Any recursive call or I went to the wrong way of this.


Ref.
[ Is "call_pending_DSRs()" only called from "unlock_inner()"? when clock
interrupt happens it will somehow enters into the "unlock_inner()" and then
"call_pending_DSRs()" which will also call the dsr() of the real time clock
but the dsr() will also make a call into the unlock_inner() so loop again??]

Thanks a lot!



-----Original Message-----
From: Andrew Lunn [mailto:andrew.lunn@ascom.ch]
Sent: Tuesday, September 24, 2002 3:35 PM
To: Qiang Huang
Subject: Re: [ECOS] how can I create real time clock interrupt? (how
Clock interrupt handled?)


 1. Cyg_RealTimeClock::isr() invoked
 --> 2. return Cyg_Interrupt::CALL_DSR|Cyg_Interrupt::HANDLED

2 just schedules the DSR to run, but do not start it.

 --> 3. call_pending_DSRs() [supplied in assembly code]
 --> 4. Cyg_RealTimeClock::dsr() invoked
 called?)
 --> 4. rtc->tick() invoked in dsr()
 --> 5. Cyg_Scheduler::unlock() called in rtc->tick()
 --> 6. unlock_inner(0) called in unlock()
 --> 7. call HAL_THREAD_SWITCH_CONTEXT then switch to destination
 thread

We are still on the interrupt stack here, so this does not case any
imeadiate effect.

--> 8. switch stack from interrupt --> user thread

Here we leave the interrupt stack and go back to a thread stack. This
can be a different stack to which we had when the interrupt happened,
this causing a thread context change.

This is how i _think_ it works. Steps 5-8 im not too sure about. Its
not often you need to know about all this, unless you are writing a
new HAL for some strange platform.

     Andrew

On Tue, Sep 24, 2002 at 02:28:54PM +0100, Qiang Huang wrote:
> Hi:
>    I have posted this onto the ecos mailing list but nobody seems to
answer
> me about this question. I have seen you on the mailing list quite a long
> time and you are quite an expert for ecos. So could I ask some detail
about
> the internal of the ecos. Thanks. (The post you answer is at the very end
as
> Ref.)
>
>
> So how will the interrupt for Clock handled in ecos?
> Is the following correct for Clock Tick interrupt process?
>
> Clock Tick process:
>
> When clock interrupt happens:
>
> 1. Cyg_RealTimeClock::isr() invoked
> --> 2. return Cyg_Interrupt::CALL_DSR|Cyg_Interrupt::HANDLED
> --> 3. Cyg_RealTimeClock::dsr() invoked(right?? how and where is dsr
> called?)
> --> 4. rtc->tick() invoked in dsr()
> --> 5. Cyg_Scheduler::unlock() called in rtc->tick()
> --> 6. unlock_inner(0) called in unlock()
> -->
> process of unlock_inner()
> --> 7. call_pending_DSRs() [supplied in assembly code]
> --> 8. switch stack from thread --> interrupt stack
>
> --> 9. calls back to the kernel to execute DSRs
> **Confused here**: At step does the DSRs include the
> Cyg_RealTimeClock::dsr()of the Cyg_RealTimeClock(which has already
> been called in step 3 above? recursive call?), if no what DSRs will
> probably called here during a Real Time Clock interrupt happens?
>
> --> 10. switch stack from interrupt --> user thread
> --> 11. call HAL_THREAD_SWITCH_CONTEXT then switch to destination
> thread
>
> BTW: how the dsr is called after the isr called? who is resposible for
> this mechanism?
>
>
> Thanks a lot.
>
> Ref.
> On Tue, Sep 24, 2002 at 01:18:08AM +0000, li hui wrote:
> > In my program ,I want to count in every real time interrupt.but it seems
> > that alarm just can count at least 10ms. how can I get RTC interrupt
> > counts?
>
> The RTC will be set to 10ms intervals. This is done automagically by
> the HAL and kernel. The details can vary a little from HAL to HAL, but
> normally there is a function hal_clock_initilize() which starts the
> clock. The kernel registers the interrupt in
> packages/kernel/current/src/common/clock.cxx and the ISR is in that
> file as well.
>
> cyg_current_time() will give you the number of ticks since system
> start, which will be the same as counting RTC ticks.
>
>        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


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