Explain the concept of priority inversion in a Real-Time Operating System (RTOS) and how it can be prevented.