Here’s a frequently cited article about real-time audio programming that should be generally applicable to other contexts:
http://www.rossbencina.com/code/real-time-audio-programming-...
In my experience in audio dev, enforcing hard real-time safety is mostly experience based: knowing to avoid locks, heap allocations, and sys calls from the real-time thread, etc.