Immediate preemption / Task switch when return from a ISR


nicolas lantz <nicolas.lantz@...>
 

Hi,

I trying to have a task waiting to put a message in a queue to be immediatly rescheduled when return from an ISR getting this msg.
For now,  the Task is set as Ready (when the ISR get the msg in the queue), but the system return in Idle Task for a long time before the Task is being executed again to prepare another msg.

The consequence is that next msg is not ready on time, while the system spent a long time in IDLE task.
I tried a lot of chosen but nothing that works.

Does somenone have a solution todo that ?


Configuration
CONFIG_PREEMPT_ENABLED=y
CONFIG_MULTITHREADING=y

My_Task as a priority of 2


Simple example code :

K_MSGQ_DEFINE(p_msgq , sizeof(msg_t), 1, 4);

My_Task()
{
    msg_t msg;

    while(1){

        do_something_to_prepare_msg(&msg);
         k_msgq_put(p_msgq, &msg, K_FOREVER);
    }

 }


My_ISR(void)
{
    msg_t msg;

    k_msgq_get(p_msgq, &msg, K_NO_WAIT);
    use_msg(&msg);
}


Thaks.
BR
Nicolas

Nicolas LANTZ
M : +33 (0)6 19 07 43 43
T : +33 (0)9 52 96 81 86
www.ubicore.net

Join users@lists.zephyrproject.org to automatically receive all group messages.