MQX Interrupt Preemption Question

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

MQX Interrupt Preemption Question

697 Views
jmag99
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

300 Views
Carlos_Musich
NXP Employee
NXP Employee


You can find a simple example in the following thread:

https://community.freescale.com/thread/324484

BR,

Carlos

0 Kudos

300 Views
matthewkendall
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