[Tinyos-devel] Nested interrupts
Michael Newman
mnewman at dragonnorth.com
Wed Aug 15 11:55:34 PDT 2007
John did excellent work on this. We both agreed that using reentrant
interrupts is not a very good practice and can lead to many issues.
-----Original Message-----
From: tinyos-devel-bounces at Millennium.Berkeley.EDU
[mailto:tinyos-devel-bounces at Millennium.Berkeley.EDU] On Behalf Of John
Regehr
Sent: Wednesday, August 15, 2007 12:24 PM
To: 'TinyOS-Devel list'
Subject: Re: [Tinyos-devel] Nested interrupts
> 1/3 to 1/10 seems reasonable.
Ok, Michael and I argued about this a bit more off-list, and I wrote a bit
of code, and the conclulsion seems to be as follows.
If the goal is to read an AVR I/O port with as little latency as possible,
both a reentrant and non-reentrant interrupt can read the port in the 10th
cycle following the interrupt trigger, including the 7 cycles that the
processor requires to take the interrupt and jump to the handler. Of
course this requires bypassing the compiler.
Then, the fastest non-reentrant interrupt enables subsequent interrupts
after 45 cycles (when it returns) and the reentrant one does this after 11
cycles. So the worst-case sampling latency is roughly 55 cycles vs. 22,
for a 2-3x improvement.
This improvement is only useful if the rest of the program keeps its
critical sections in the same ballpark as 11 cycles.
Code attached is my fastest non-reentrant handler which assumes a
32-element ring buffer for samples. I expect someone clever could shave a
few cycles off this but it seems pretty close to optimal in terms of both
sampling latency and overall cycles.
Hopefully this is useful for people doing tight sampling...
John
More information about the Tinyos-devel
mailing list