Embedded Rust RTOS vs. C RTOS

(tweedegolf.nl)

33 points | by kooi 2 hours ago

4 comments

  • Animats 50 minutes ago
    That's under very light CPU load. So an async approach, with no preemption, can work. If there's any significant compute going on, it won't work as well.

    A useful number to measure on a scope is worst case interrupt latency. This is what matters if there's a hard real-time constraint. They measured standard deviation, but not worst case. The usual test setup is that an input signal (typically a square wave) goes to an input pin, interrupt happens if interrupts not prevented, task starts, task turns on an output pin. You watch input to output delay on a scope and look for outliers.

    If you're running entirely run to completion, the outliers are determined by the longest compute task. This is a problem if there's a compute task.

    This is historically where QNX shines. Interrupt is processed and schedules a thread. About all that happens at interrupt level is thread activation. The thread turns on the output pin. You can look on a scope for scheduling outliers. The best case latency is higher than doing the work at interrupt level, but the worst case latency is constant, even if lower priority threads are compute bound.

    This is the difference between real time and "near real time" scheduling.

    • yuriks 29 minutes ago
      Embassy can (these days, not sure if this is more recent than the article) do preemption, but it works by setting up multiple task pools and executors for each priority level: https://docs.embassy.dev/embassy-executor/git/cortex-m/struc... Non-realtime compute heavy tasks can be processed in the background executor and interrupted by latency sensitive ones.
    • AnyTimeTraveler 27 minutes ago
      In my experience, it is pretty rare to run much actual work on a microcontroller. Testing at effectively idle represents most of my usecases.

      For the times where there is a background load: RTIC has task priorities and pre-emption, so you can run your compute-intensive task with a lower priority and react to interrupts in a timely manner.

    • wiremine 30 minutes ago
      Agreed. I really like Embassy, and the write up is a fun read. But, this isn't what "real" embedded software looks like.
    • kjs3 33 minutes ago
      When your goal is to show your pet language is 'better', you pick the benchmarks that 'prove' it.
      • inamberclad 28 minutes ago
        No, this is really the whole point of an RTOS. It can preempt low priority tasks to respond to critical events.
        • kjs3 21 minutes ago
          I'm quite clear on what the point of an RTOS is, thank you. But I wasn't addressing that, which is the point you seem to have missed.
  • CupricTea 20 minutes ago
    Title should be changed. Async Rust != RTOS. RTOS's are preemptively multithreaded while async is done cooperatively with yield points.

    Perhaps "Embedded async Rust vs. C RTOS"

  • vatsachak 1 hour ago
    Those damn compilers are going to take our jobs!!!
  • aw1621107 50 minutes ago
    (2022)