5 ms·
To be fair, a 8MHz (16MHz?) CPU is also a huge liability when you have strict timing requirements. For almost anything, the Pi will probably give you better gua
by marcosdumay 11y ago
To be fair, a 8MHz (16MHz?) CPU is also a huge liability when you have strict timing requirements. For almost anything, the Pi will probably give you better guarantees by sheer speed... and you can always compile the kernel with a real-time patch.
Not saying running on the bare metal is worthless, but an Arduino is a really low end board.
- joshvm 11y agoI think that's confusing liability with speed. Running interrupt-free code on an ARM or AVR is incredibly reliable. I would argue much more reliable than going to the length of patching the kernel. Just because it's slow doesn't mean you can't predict what's going to happen, they're two separate issues.
- Sanddancer 11y agoYes, but even with rt-linux, you've got a jitter of potentially several dozen microseconds, and each interrupt routine will vary. With an AVR, your delay is 4 clock cycles every time, which comes out to .2 microseconds at 20 Mhz. This is the kind of guarantee you can get with being on an intimate level with the chip which you can't get with any OS.
- deleted 11y ago[deleted]
- eru 11y agoAt least not any OS that's not geared for realtime from the ground up.
- tremon 11y agoIt's not just about the OS, it's about the platform (hardware). Even with a fully-optimized RTOS on a standard PC platform, you might run into millisecond-latency due to non-maskable interrupts, cache misses or bus contention (DMA bus-mastering kills any real-time guarantees). That's not even considering the stalls introduced by SMM or TPM instructions.
- jevinskie 11y agoI would think it would be difficult to achieve the low jitter of a simple, fixed # of cycles / instruction, architecture like AVR in a superscalar, cached, speculative architecture like modern X86 CPUs. A hard RTOS is necessary, but perhaps not sufficient with most X86 microarchs. Maybe you can disable some of that dynamic behavior via MSRs but probably not all.
- Unklejoe 11y agoTiming requirements don't necessarily translate to _speed_ requirements. Microcontrollers like the Arduino/Atmel are perfect for situations where you need to guarantee that some signal will be asserted exactly 250 (no more, no less) nanoseconds after some other external event, _no_matter_what_. Since there's usually no OS running on something like an Arduino, you're basically forced to write very deterministic event driven programs. Also, since most (maybe all) instructions on those Atmel microcontrollers execute in a single clock cycle, you can easily dissect your C functions and know exactly how long they will take to execute. I wouldn't trust Linux for such an application even with a "real time" scheduler. Linux as a RTOS certainly has it's place, but it's best left for systems that can actually benefit from the added complexity. For most typical microcontroller projects, the extra features of a full Linux kernel would just get in the way. Note: There's nothing stopping someone from using a RPI in such a way as well (bare metal), but they are really geared for more complex applications, so there isn't as much support in that area. Also, the hardware is probably a little more complex. Therefore, my statements assume we're comparing an Arduino to an RPI running Linux.
- blhack 11y ago>Microcontrollers like the Arduino/Atmel are perfect for situations where you need to guarantee that some signal will be asserted exactly 250 (no more, no less) nanoseconds after some other external event, _no_matter_what_. What is an example of something like that?
- viraptor 11y agoSampling from external sensors for example. If you're measuring something changing over time, you may need very precise timing.
- quanticle 11y agoMusic, for example. If you're doing audio processing for music, it's much more preferable to have something that takes 20ms consistently to transform an input than something that takes 5ms 90% of the time and 50ms 10% of the time (due to, e.g. interrupts). That 50ms gap will show up as a note that's audibly behind the beat, while the improvement from 20ms to 5ms isn't really that beneficial. EDIT: another example is controlling a UAV. You can design around a system that consistently takes 20ms to process an input (e.g. by limiting the max speed). It's a lot more difficult to design around a component that takes 5ms most of the time, but will randomly take 50ms here and there, because you don't get to control when those lag spikes happen.
- winter_blue 11y agoCouldn't you write a really simple kernel[1] or bootstrapping program, and effectively run your program without an OS? Does an architecture (ARM / AVR / x86) limit the possibility of writing real-time code if the code is the OS, and just runs on the bare metal? Your program would run in ring 0, be the only "process" and have full access to RAM. You decide whether you want to handle interrupts or not. (I assume there's a way to select what interrupts you want to handle.) [1] For e.g., this tutorial explains how to write a basic x86 kernel: http://www.jamesmolloy.co.uk/tutorial_html/ http://www.jamesmolloy.co.uk/tutorial_html/
- mnw21cam 11y agoThere's no such thing as bare metal any more. https://en.wikipedia.org/wiki/System_Management_Mode https://en.wikipedia.org/wiki/System_Management_Mode - the CPU itself may at times spend some time doing "other things" such as changing the spin speed of the cooling fans, or interpreting the signals from the USB keyboard. The OS (running in ring 0) has no control over this - the CPU effectively just pauses for a little bit every now and again.
- pjc50 11y agoI'm not aware of any ARM systems that have this yet.
- jevinskie 11y agoTrustZone. It is "one level deeper" just like any other hypervisor or monitor. As far as I know, it is quite common in Android phones for HSM and DRM purposes. Yay? =\ http://www.arm.com/products/processors/technologies/trustzone/ http://www.arm.com/products/processors/technologies/trustzon... Edit: And, of course, it is probably exploitable in some way. See http://bits-please.blogspot.com/2015/08/exploring-qualcomms-trustzone.html http://bits-please.blogspot.com/2015/08/exploring-qualcomms-...
- sklogic 11y agoCan you bit-bang a 640x480 VGA on a Pi? No. Not even in bare metal, no OS. But a lowly attony85 can do it easily.
- hatsunearu 11y agoGenerally there is a trade-off between latency and throughput. Embedded Linux is generally geared towards more throughput than latency. Microcontrollers have less throughput-oriented features (threads, for instance), which makes them very well suited for latency-critical real time stuff.