MQX Interrupt Preemption Question

Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX Interrupt Preemption Question

Contributor II

I have a quick question about the operation of MQX.  Let's say we have the following senario:

Low Priority Task Running

Interrupt Occurs and causes a higher priority task to become ready to run.

Upon exiting from the ISR, does MQX immediately task switch to the higher task, or does it wait for the next systick period before changing context?

I believe most RTOS immediately change, but we are not seeing this behavior on our system.  We are seeing it wait until the next system tick period before changing to the higher priority task.

0 Kudos
2 Replies

NXP Employee
NXP Employee

You can find a simple example in the following thread:



0 Kudos

Contributor V

The newly ready-to-run task should run immediately.

There is an explanation of how this works in the MQX User Guide, section 3.9. Essentially there is a Kernel interrupt that acts as a wrapper around user-defined interrupt code. When the user-defined ISR returns, it returns to the kernel ISR which executes a context switch if required.

For this to work you need to install your ISR using the mechanisms provided (i.e. _int_install_isr, see 3.9.2). If you just hook user-defined ISR code to raw interrupt vectors then MQX will have no knowledge that anything has happened, and you won't see a context switch until the next tick.

0 Kudos