Hello everybody !
I have some trouble with Multithreading settings on Kinetis Design Studio. In fact, I have the KL25Z board and I need for my project to have several threads running at the same time. I am using the Processor Expert Mode on Kinetis, have added MQXLite component and have created few tasks.
But on running step, the tasks runs consecutively (one after the other). What I want is each tasks runs at the same time (for example, several quantum for the first tasks executed followed by several quantum for the second tasks with a scheduling algorithm).
Do you have any ideas or maybe some example ?
Thanks :smileywink:
Solved! Go to Solution.
In fact KL25Z is single core MCU, therefore core could execute just one task at the same time.
Typical solution is that all tasks running in endless loops:
While(1){
//task code
}
Unfortunately MQX Lite doesn’t offer Round Robin (Time Slice) scheduling option. Task switching mechanism is based on priority – higher priority=lower priority number runs first.
Therefore you need synchronization objects.
If your tasks runs at the same priority, you can simple call _sched_yield() function for move current task to end of ready queue and execute next task.
Other option is _time_delay_for()/_time_delay_until() functions – it suspends the active task for/until the specified time.
However most important synchronization objects are Lightweight events, Lightweight semaphores, Lightweight messages and Mutexes.
These synchronization objects could be used for task switching between active/blocked and ready states.
For example _lwevent_wait_for() function will cause switch active tasks to blocked state, until appropriate bit will be set (by _lwevent_set() function) or until specific time (in ticks). In that case another ready task with highest priority will be executed…
The easiest way how to start with MQX Lite operating system is through example applications.
CodeWarrior examples are available at:
CodeWarrior}\MCU\CodeWarrior_Examples\Processor_Expert\MQXLite directory.
In KDS:
KDS_2.0.0\eclipse\ProcessorExpert\Projects\Kinetis\MQXLite\..
In KSDK (If you use MQX for KSDK with Lite configuration):
KSDK_1.1.0\rtos\mqx\mqx\examples\
See also MQX Lite User Guide:
http://www.freescale.com/files/soft_dev_tools/doc/user_guide/MQXLITEUG.pdf
and MQX Lite Reference Manual:
http://www.freescale.com/files/32bit/doc/ref_manual/MQXLITE_RM.pdf
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
In fact KL25Z is single core MCU, therefore core could execute just one task at the same time.
Typical solution is that all tasks running in endless loops:
While(1){
//task code
}
Unfortunately MQX Lite doesn’t offer Round Robin (Time Slice) scheduling option. Task switching mechanism is based on priority – higher priority=lower priority number runs first.
Therefore you need synchronization objects.
If your tasks runs at the same priority, you can simple call _sched_yield() function for move current task to end of ready queue and execute next task.
Other option is _time_delay_for()/_time_delay_until() functions – it suspends the active task for/until the specified time.
However most important synchronization objects are Lightweight events, Lightweight semaphores, Lightweight messages and Mutexes.
These synchronization objects could be used for task switching between active/blocked and ready states.
For example _lwevent_wait_for() function will cause switch active tasks to blocked state, until appropriate bit will be set (by _lwevent_set() function) or until specific time (in ticks). In that case another ready task with highest priority will be executed…
The easiest way how to start with MQX Lite operating system is through example applications.
CodeWarrior examples are available at:
CodeWarrior}\MCU\CodeWarrior_Examples\Processor_Expert\MQXLite directory.
In KDS:
KDS_2.0.0\eclipse\ProcessorExpert\Projects\Kinetis\MQXLite\..
In KSDK (If you use MQX for KSDK with Lite configuration):
KSDK_1.1.0\rtos\mqx\mqx\examples\
See also MQX Lite User Guide:
http://www.freescale.com/files/soft_dev_tools/doc/user_guide/MQXLITEUG.pdf
and MQX Lite Reference Manual:
http://www.freescale.com/files/32bit/doc/ref_manual/MQXLITE_RM.pdf
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks for your help RadekS ! :smileywink:
Now I get how MQX Lite works !
Nevertheless, I have found an other way to resolve my problem: my main task is the blinking of LEDs which are managed using a PWM.
So I will initialize my PWM with a specific intensity and frequency, and my other tasks will be executed consecutively at the same time (in a while(1)) without stopping the blinking of my LEDs: That's what I wanted to do !