|
|
||||
You may redistribute this newsletter for noncommercial purposes. For commercial use contact jack@ganssle.com. To subscribe or unsubscribe go to https://www.ganssle.com/tem-subunsub.html or drop Jack an email. |
||||
Contents | ||||
Editor's Notes | ||||
Did you know it IS possible to create accurate schedules? Or that most projects consume 50% of the development time in debug and test, and that it’s not hard to slash that number drastically? Or that we know how to manage the quantitative relationship between complexity and bugs? Learn this and far more at my Better Firmware Faster class, presented at your facility. See https://www.ganssle.com/onsite.htm. |
||||
Quotes and Thoughts | ||||
"There are only two kinds of languages: the ones people complain about and the ones nobody uses." - Bjarne Stroustrup |
||||
Tools and Tips | ||||
Please submit clever ideas or thoughts about tools, techniques and resources you love or hate. Here are the tool reviews submitted in the past. Bill Gatliff had some more thoughts about compilers:
I mentioned the slide rule last issue. Don De Witt and Phil Martel sent this link to a slide rule emulator. If you grew up using rules you'll get a kick out of it. Martin Thompson wrote about the Red Pitaya, a USB scope/logic analyzer:
Siglent sent the 100 MHz version of their SDS 1102CML digital scope for review. This is a bench top instrument, not a USB scope. Within the next month or two I'll post a full analysis. My initial impression after an hour or two operating it is that it packs a tremendous amount of capability into a $379 instrument. |
||||
On Enabling Interrupts Inside ISRs | ||||
Do you re-enable interrupts in your interrupt service routines (ISRs) early, rather than just before the return? In the past I have advocated for turning interrupts back on as early as possible, in most cases, so other events can get serviced. But Phil Koopman, in a recent blog post, has challenged that thinking. Phil kindly allowed me to repost that here. And, I highly recommend his blog which lately has had a number of interesting postings about safety in embedded systems. Phil's post: A previous post on rules for using interrupts included the rule:
Some developers take a different point of view, and feel that it is best to re-enable interrupts to let higher priority ISRs run without delay. The idea is that high priority interrupts should run as soon as possible, without having to wait for low priority interrupts to complete. Re-enabling interrupts within an ISR seems to let that happen. BUT, while there might be some intuitive appeal to this notion, this is a dangerous practice that makes things worse instead of better.
You could say "the highest priority ISR doesn't re-enable interrupts" -- but what about the second-highest priority ISR? Once you get more than a couple ISRs involved this gets hopeless to untangle. You could try to write some sort of ISR handler to mitigate some of these risks, but it's going to be difficult to get right, and add overhead to every ISR. In all, the situation sounds pretty messy and prone to problems .. and it is. You might get away with this on some systems some of the time if you are really good (and never make mistakes). But, getting concurrency-related tricky code right is notoriously difficult. Re-enabling interrupts is just asking for problems. The worst case is that the longest-running low priority ISR runs to completion, making all the higher priority ISRs wait for it to complete before they can start. But after that all the remaining ISRs that are pending will complete in priority order -- highest to lowest priority. That's exactly what you want except for the low priority ISR clogging up the works. So if you have an obnoxiously long low priority ISR that's a problem. But if none of your ISRs run for very long (which is how you're supposed to write ISRs), you're fine. Put into scheduling terms, you want to make sure none of your ISRs runs long, because a long-running ISR gives you a high blocking time, and blocking time delays high priority tasks from completing. Let's compare outcomes for the two alternative strategies. If you re-enable interrupts, the worst case latency for the highest priority ISR in the system is that it arrives, and then gets preempted by every other ISR in the system (including the longest-running ISR if it comes in later, but before the high priority ISR has a chance to complete). If you leave interrupts masked, the worst case is that the longest-running ISR has to complete, but then the high priority ISR goes immediately afterward. So, leaving interrupts disabled (masked) during every ISR is clearly a win for the worst case, in that you only have to wait for the longest-running ISR to complete before running the highest priority ISR, instead of waiting for all ISRs to complete. The worst case is typically what you care about in a real time embedded system, so you should leave interrupts disabled in ISRs to ensure the fastest worst-case completion time of high priority ISRs. And, leaving interrupts disabled in ISRs also gets rid of the risks of stack overflow and re-triggered ISRs we mentioned. UPDATE: To avoid confusion, it's important to note that the above is talking about what happens at ONE level of interrupts, such that when one ISR is running no other interrupts run until the ISR completes or ISRs at that level complete. Many architectures have multiple levels, in which one ISR can interrupt another ISR at a lower level even if that lower level has interrupts masked. This corresponds to the comment about one ISR per level being active in the worst case. Also, note that if an architecture can change the priorities of interrupts within a single level that's irrelevant -- it is the existence of levels that are each individually maskable and that are prioritized as groups of interrupts per level that gives a way around some of these problems. So, going back to the title says, do not RE-enable the same level of interrupts within an ISR. |
||||
A Software Team Test | ||||
John Black sent this link, which is Joel Spolsky's 12 points for evaluating the health of a software team. Joel is the author of the joalonsoftware blog, which was (maybe still is) a hugely popular site. It's rarely updated anymore. The twelve points take almost no time to check, and in the past I've recommended them as a way to decide if you should accept a job from an organization. The list doesn't pretend to be complete or scientific, but is a terrific set of rules of thumb. |
||||
Jobs! | ||||
Let me know if you’re hiring embedded engineers. No recruiters please, and I reserve the right to edit ads to fit the format and intents of this newsletter. Please keep it to 100 words. |
||||
Joke For The Week | ||||
Note: These jokes are archived at www.ganssle.com/jokes.htm. What you DON'T want to hear your System Administrator say: 82. We prefer not to change the root password, it's a nice easy one... (To be continued). |
||||
Advertise With Us | ||||
Advertise in The Embedded Muse! Over 23,000 embedded developers get this twice-monthly publication. . |
||||
About The Embedded Muse | ||||
The Embedded Muse is Jack Ganssle's newsletter. Send complaints, comments, and contributions to me at jack@ganssle.com. The Embedded Muse is supported by The Ganssle Group, whose mission is to help embedded folks get better products to market faster. |