Live data from Hacker News

Fearless concurrency in your microcontroller

blog.japaric.io

31–40 of 52 posts

Re: Fearless concurrency in your microcontroller

#31
Neat to see given I submitted RTFM-core recently:

https://news.ycombinator.com/item?id=14294408

So, the author learned from it, ported it to a safer language, and release the results. Although Ada/SPARK Ravenscar did embedded concurrency, the author certainly builds on modern methods for achieving similar (possibly better) results in Internet of Things. Good work. :)

Re: Fearless concurrency in your microcontroller

#32
post #11

Earlier quoted context omitted.

Yes, some examples, this list is not exhaustive. - Oberon, http://www.astrobe.com/default.htm - Java, http://www.microej.com/resources/supported-platforms/ - Pascal and Basic, https://www.mikroe.com/stm32/ - Ada, http://blog.adacore.com/tag/STM32

No offense, but nobody in their right mind is going to use any of this in a production environment. For instance, what will your hypersonic rocket do while garbage collection is running instead of it's real-time control loops?

There's a lot of them:

https://en.wikipedia.org/wiki/Embedded_Java

A particular vendor (formerly Aonix) that always had interesting innovations in runtimes, tradeoffs, FFI's, and so on:

http://www.businesswire.com/news/home/20050307005203/en/Aoni...

https://www.ptc.com/developer-tools/perc

Each of them is a company making serious money in embedded systems. A few do safety-critical. I'll let you wonder whether they were in their right mind for building Java apps and using Java runtimes that don't seem to fail in high-stakes circumstances.

Re: Fearless concurrency in your microcontroller

#33
post #26
post #23

Earlier quoted context omitted.

How many examples from military systems using real time Java do you want me to provide? I can also provide examples for energy motoring, copiers, factory control systems and phone infrastructures.

I've never heard of "real time Java" before—is it soft real-time, like Erlang; or hard real-time, like QNX? What are the concurrency primitives? (Threads? Actors?)

Follow this link...

https://www.google.com/#q=real-time+java

...to get a Wikipedia summary, standards body, a tutorial, and probably some products. It's more useful than Google usually is on some terms like this that might muddy up search results.

Re: Fearless concurrency in your microcontroller

#34
post #29
post #24

Earlier quoted context omitted.

I guess the French and US military using Aonix real time JVMs for weapons control and monitoring are the right set of persons to answer your question. Also some military think memory leaks are irrelevant on missiles, given the ultimate garbage collector.

Heh - saw that on Twitter last week: https://twitter.com/pomeranian99/status/858856994438094848 "Memory leaks on missiles don't matter, so long as the missile explodes before too much leaks."

It's called real-time, garbage collection. It occurs predictably on regular intervals before enough leaks happen to blow missiles up or whatever other tragedy. Aonix and some other vendors have had it for a long time now. Meanwhile, mainstream found out in the past, few years that Go could achieve "low-latency" garbage collection. The field can do more than many of them think given the countless person-years invested in so much GC research and product development. I can't even track all of the GC's especially once they started using genetic algorithms and such to automatically make them.

EDIT to add: It says "Ada" and "Rational." That's an Ada forum. That language has little protection for temporal safety in the 1990's. More than many but not at Rust level or full leak prevention.

Re: Fearless concurrency in your microcontroller

#35
post #23

Earlier quoted context omitted.

How many examples from military systems using real time Java do you want me to provide? I can also provide examples for energy motoring, copiers, factory control systems and phone infrastructures.

One mission critical system, where failure is not an option, such as on a hypersonic rocket. One actual combat system - not a terminal for use on base, but something you have to rely on when people are shooting at you. One.

Those go through certification processes. It's been against the rules to use a GC even if it's hard-real-time. Here's an example where the author points out the real-time Java was designed for DO-178B (safety-critical aerospace) but it wasn't until DO-178C that they even considered allowing a GC:

http://www.aicas.com/papers/EmbeddedWorld2009-Andy-Walter.pd...

The companies that develop reusable solutions for multiple markets tend to pick something easy to certify or sell to all of them. So, if Java wasn't allowed, they'd lean toward something else in their products targeting highest-assurance just to reduce costs. That's mostly been assembly, C and Ada that I've seen.

Meanwhile, we do have proof it can be done in things such as the Sandia Secure Processor that they'll use for some of highest-assurance applications. The first-pass silicon they got was also nice. The best articles by Wickstrom et al on SSP are paywalled in ACM and IEEE if you have access. If not, there's a link below on how they built it with brief description of it under "Score processor," another name.

http://www.sandia.gov/LabNews/LN01-11-02/key01-11-02_stories...

https://www.researchgate.net/publication/236425094_Sandia_se...

ftp://ftp.cs.kent.ac.uk/people/staff/phw/.old-1999/tmp2/443-cpa2007-wickstrom.pdf

Re: Fearless concurrency in your microcontroller

#36
post #18

Nice article. Some good insights, as well as beginner how-to steps. The embedded industry has proven to be very resistant to innovations and modern code-writing practices. Some platforms I coded for didn't even support/allow C99 standard. C++ is gaining some foothold (mbed, for example). Developers don't feel the urge to catch on with times, like in other industries. And yet, now they are expected to write secure IoT…

"The embedded industry has proven to be very resistant to innovations and modern code-writing practices .... And yet, now they are expected to write secure IoT systems." Those are opposing goals.

I second that. Conservative nature of embedded industry led to lots of investment into things like static analysis, WCET's, and automated testing of few languages or platforms they use. Embedded is one of few sectors that can benefit from most deliverables in high-assurance field as well since they structure their stuff simple enough for that vs piles of Linux, containers, bloated apps, etc. The innovation happens outside of the coding mostly. That's why the coding keeps the quality that engineers intended to put into it. :)

Re: Fearless concurrency in your microcontroller

#37
That's a very nice use of Rust's safety. This tasking model is a common way to write programs for very small machines, but with this, it's safe. People have a very hard time getting all that priority-level adjustment right.

It's not concurrency, though. It's asynchrony. Two things never happen at at the same time.

Modula I for the PDP-11 did do all this in 1979. In addition, it computed the worst-case stack for each task, so you were sure you couldn't run out of memory if enough preemption occurred. Today this is mostly an issue on very low-end machines, but this code is for machines like very low end ARM processors, where you might run out of stack. Some test fixture to force worst case stack use, with all the priorities stacked up, would be useful.

Re: Fearless concurrency in your microcontroller

#38
post #23

Earlier quoted context omitted.

How many examples from military systems using real time Java do you want me to provide? I can also provide examples for energy motoring, copiers, factory control systems and phone infrastructures.

One mission critical system, where failure is not an option, such as on a hypersonic rocket. One actual combat system - not a terminal for use on base, but something you have to rely on when people are shooting at you. One.

Thanks for making my life easy.

USS Bunker Hill ballistic missile defense system weapons control.

http://www.militaryaerospace.com/articles/2010/04/aonix-perc...

"The Aegis Weapon System is the premier naval defense system and the sea-based element of the U.S. Ballistic Missile Defense System. Its precision SPY-1 radar and integrated command and control system guides the interceptor and uplinks target track information to the missile for terminal homing. Its ability to detect, track, and engage targets ranging from sea-skimming cruise missiles to ballistic missiles in space is proven."

Good enough for mission critical system, hypersonic rockets, combat system firing at me?

If not, I can provide other ones, better suited to your use cases.

Re: Fearless concurrency in your microcontroller

#39
post #12

Nice article. Some good insights, as well as beginner how-to steps. The embedded industry has proven to be very resistant to innovations and modern code-writing practices. Some platforms I coded for didn't even support/allow C99 standard. C++ is gaining some foothold (mbed, for example). Developers don't feel the urge to catch on with times, like in other industries. And yet, now they are expected to write secure IoT…

It was my understanding that C++ was being abandoned in the embedded world in favor of C due to the failure of UML. See for example, the intro of this (possibly outdated) article: http://embeddedgurus.com/state-space/2008/01/object-based-pr... Is this changing now?

I didn't glean that the author is implying UML influenced language choice, just that UML vendors tried to sell to C developers.

But to answer your question, C++ is gaining a larger foothold in embedded if anything. More and more libraries are written in C++, and it's becoming more supported in the various toolchains.

From a very recent hackaday article - "Modern C++ allows us to write cleaner, more concise code, and make the code we write more reusable. The following are [...] new features of C++ that don’t add memory overhead, reduce speed, or increase size because they’re all handled by the compiler [...] after reading this you’ll be more aware of the newer features as we start to see them roll out in Arduino code."

http://hackaday.com/2017/05/05/using-modern-c-techniques-wit...

And also, because I was poking around their github today, here is Flybrix's source code, a lego-drone startup writing C++ on a Kinetis K-20 microcontroller (100 MHz ARM Cortex-M4). They use the teensy bootloader, which is why you see a mix of Arduino and C++ files

https://github.com/flybrix

Re: Fearless concurrency in your microcontroller

#40
post #29

Earlier quoted context omitted.

Heh - saw that on Twitter last week: https://twitter.com/pomeranian99/status/858856994438094848 "Memory leaks on missiles don't matter, so long as the missile explodes before too much leaks."

It's called real-time, garbage collection. It occurs predictably on regular intervals before enough leaks happen to blow missiles up or whatever other tragedy. Aonix and some other vendors have had it for a long time now. Meanwhile, mainstream found out in the past, few years that Go could achieve "low-latency" garbage collection. The field can do more than many of them think given the countless person-years invested…

Seems AdaCore is working to add some form of borrow-checker to Spark :-) https://cps-vo.org/node/34575
Post reply on HN