Re: [EE] Ideas about improving safety in C language
Sean Breheny <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <CAE8uMMpHD5twnWJDjz_ujp7yhf5OPuHiJJ8G20SiUFvnuaA=uQ@mail.gmail.com> |
There is a subset of C, combined with extra rules about use and software which checks to make sure the rules are being followed, which is called MISRA C and is often used for life critical safety applications. It has a pretty good record from what I understand. It is rather old now (it was developed 30 years ago but has been updated several times and is still in widespread use. They supposedly have a version for C++ but since C++ relies on garbage collection and other background tasks I don't see how it really can be "safe" unless you essentially reduce it to C with a few minor enhancements. I have written safety-critical FPGA logic in VHDL and had it pass the requirements placed on it by auditors (after I made some changes they requested). I was not required to use special synthesis software or restrict the language constructs I used (other than the usual recommendations and restrictions which are needed for synthesizability). This was for a SIL 2 application so not like a nuclear power plant or airplane autopilot. Just a safety system for industrial machines. On my own I made almost every part of the logic check itself periodically and lock-out if it failed the test. Many of the functions were redundant with lock-out on comparison failure and some of them were 2 of 3 redundant (two out of 3 have to fail to cause a dangerous fault). I also forced the synthesis engine to put the safety part of the logic in one section of the FPGA and constrained the IO from it to the rest of the logic to a minimum number of signals and we did extensive testing at that interface level and at each submodule. We could then freely make changes to the bulk of the logic without re-approval as long as we didn't touch the safety logic. FPGA's lend themselves well to this kind of safety structure. With C code compiled and running on processors, you often also need to run multiple processors in lock-step and compare their outputs as well as run periodic diagnostics. All of that is separate from MISRA standards. Sean On Tue, Apr 15, 2025 at 4:33 PM smplx <[email protected]> wrote: > > > On Tue, 15 Apr 2025, Isaac Marino Bavaresco wrote: > > > Hi folks, > > > > I was thinking about the current discussion about C/C++ language safety, > > and I recalled an old idea I had long ago about creating a new string > > format and library. > > > > It could be possible for one person alone to implement and use it > > privately, but of course it would be even better if it becomes a > > standard, perhaps with support from the compilers. > > > > I don't know whether something similar was already suggested or is being > > used, but I would like to know your opinion about it. > > > > > -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at https://mailman.mit.edu/mailman/listinfo/piclist