Hacker News new | past | comments | ask | show | jobs | submit login

A real time system can be cooperative. A real time operating system can use pre-emption to achieve bounded latency. A real time system that does not use pre-emption can use other mechanisms -- including a combination of analytical bounding of task run-times and static cooperative scheduling -- to achieve bounded latency. The latter system can be enhanced by enforcing the analytical bounds, making it somewhat robust to errors in analysis. One can argue that this enforcement makes the system non-cooperative, it's certainly not full pre-emption with all the costs and benefits that go with.

As an example of such a system, consider a bare metal BLDC motor driver. You may statically schedule a sequence of tasks -- read current sensors, read commands, adjust PWM hardware registers, read temperature sensors, change state on temperature error, loop. Suppose that the 'read temperature sensors' task can fail to meet its analytic time budget because the I2C hardware can get into a weird state and just not return. (Suppose further that this isn't hypothetical...) Then having a kill-and-reset-on-timeout feature for the temperature sensor task is an obvious and reasonable workaround to give an improved system. That feature can be added to the temperature sensor task; or, it can be added as a general feature to the round robin scheduler in the way I described.

Hope that's a helpful description of what I was trying to explain! I'm not in any way saying this is a general solution or a universal replacement for a real RTOS; rather that it's a pattern I've ended up re-deriving a time or two that I find interesting.




Heh. I2C was part of what I was doing on the aforementioned MSP430 OS. I ended up breaking up all the I2C stuff into parts of a state machine (I think I ended up with six states), and ran it in the background as the lowest priority main loop.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: