ClockCyckles()

bridged with qdn.public.qnxrtp.sh4
Post Reply
Martin Nylund

ClockCyckles()

Post by Martin Nylund » Fri Dec 19, 2003 8:45 am

Does anyone know where the ClockCyckles() function fetches its return value
on a SH4 platform? Why is this function not concidered interrupt handler
safe (see doc)? Is it possible to get this value in a "safe way" in ISR
(what I need are timestamps)?

Thanks
Martin

David Gibbs

Re: ClockCyckles()

Post by David Gibbs » Fri Dec 19, 2003 10:37 pm

Martin Nylund <mnylund@emtrion.de> wrote:
Does anyone know where the ClockCyckles() function fetches its return value
on a SH4 platform?
Take a look at /usr/include/sh/neutrino.h which implements it.
Why is this function not concidered interrupt handler
safe (see doc)? Is it possible to get this value in a "safe way" in ISR
(what I need are timestamps)?
I think it should be safe, actually.

-David
--
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Adam Mallory

Re: ClockCyckles()

Post by Adam Mallory » Sat Dec 20, 2003 5:26 am

David Gibbs <dagibbs@qnx.com> wrote in message
news:brvujo$4no$2@nntp.qnx.com...
Martin Nylund <mnylund@emtrion.de> wrote:
Does anyone know where the ClockCyckles() function fetches its return
value
on a SH4 platform?

Take a look at /usr/include/sh/neutrino.h which implements it.

Why is this function not concidered interrupt handler
safe (see doc)? Is it possible to get this value in a "safe way" in ISR
(what I need are timestamps)?

I think it should be safe, actually.
It's marked unsafe, since some processors don't provide a real running
counter which can easily be fetched. If emulation is required, you wouldn't
want to take a trap inside an interrupt handler or run emulation code in an
interrupt code path. Take a look at the header, and if your processor
supports the fetch of the counter, it should be safe to call in an ISR
handler.

-Adam

Martin Nylund

Re: ClockCyckles()

Post by Martin Nylund » Mon Jan 05, 2004 9:28 am

"Adam Mallory" <amallory@qnx.com> schrieb im Newsbeitrag
news:bs0m8q$sci$1@nntp.qnx.com...
David Gibbs <dagibbs@qnx.com> wrote in message
news:brvujo$4no$2@nntp.qnx.com...
Martin Nylund <mnylund@emtrion.de> wrote:
Does anyone know where the ClockCyckles() function fetches its return
value
on a SH4 platform?

Take a look at /usr/include/sh/neutrino.h which implements it.

Why is this function not concidered interrupt handler
safe (see doc)? Is it possible to get this value in a "safe way" in
ISR
(what I need are timestamps)?

I think it should be safe, actually.

It's marked unsafe, since some processors don't provide a real running
counter which can easily be fetched. If emulation is required, you
wouldn't
want to take a trap inside an interrupt handler or run emulation code in
an
interrupt code path. Take a look at the header, and if your processor
supports the fetch of the counter, it should be safe to call in an ISR
handler.

-Adam


The value seems to come direct from the 32bit counter TCNT1 in TMU. Thanks
for your help.

-Martin

David Gibbs

Re: ClockCyckles()

Post by David Gibbs » Mon Jan 05, 2004 4:12 pm

Adam Mallory <amallory@qnx.com> wrote:
David Gibbs <dagibbs@qnx.com> wrote in message
news:brvujo$4no$2@nntp.qnx.com...
Martin Nylund <mnylund@emtrion.de> wrote:
Does anyone know where the ClockCyckles() function fetches its return
value
on a SH4 platform?

Take a look at /usr/include/sh/neutrino.h which implements it.

Why is this function not concidered interrupt handler
safe (see doc)? Is it possible to get this value in a "safe way" in ISR
(what I need are timestamps)?

I think it should be safe, actually.

It's marked unsafe, since some processors don't provide a real running
counter which can easily be fetched. If emulation is required, you wouldn't
want to take a trap inside an interrupt handler or run emulation code in an
interrupt code path. Take a look at the header, and if your processor
supports the fetch of the counter, it should be safe to call in an ISR
handler.
Hm...perhaps the docs should include a note as to when it is/isn't
safe to use in an interrupt handler, or some idea on how to figure
it out?

(Though, I thought that the instrumented kernel used the same
mechanism for time-stamping events, so it had to be safe to use
in-kernel for all processors, now?)

-David
--
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Adam Mallory

Re: ClockCyckles()

Post by Adam Mallory » Mon Jan 05, 2004 7:01 pm

David Gibbs <dagibbs@qnx.com> wrote in message
news:btc2e1$1ei$3@nntp.qnx.com...
Hm...perhaps the docs should include a note as to when it is/isn't
safe to use in an interrupt handler, or some idea on how to figure
it out?
Yes, I would say that it should be at least mentioned.
(Though, I thought that the instrumented kernel used the same
mechanism for time-stamping events, so it had to be safe to use
in-kernel for all processors, now?)
Yes, I should be a little more clear. It should be safe, but it could be
unwise to take a trap or do emulation (or both in case the emulation is
implemented via a trap) during ISR time.

-Adam

Post Reply

Return to “qdn.public.qnxrtp.sh4”