Hi,
I am working on CodeWarrior v10.2 and of MQX v4.0.
I am using LWMSG for task communication and for that I am using LWMSG demo of MQX.
But there is a little bit doubt that I want to clear.
My query is, In demo code time_delay_ticks(1) ; is written. As both task have same priority and lwmsg_receive() function is itself one kind of delay than why one have to put delay by calling time_delay_ticks();??
In my code I am using lwmsg_receive() function. Problem is in a one task it is waiting for receive a msg even without delay function. And for the other task it is not waiting for the message and executing the next code below msg receive. Note that both task in my program also have the same priority.
I need to clear my confusion. can anybody tell me??
Regards,
Utsavi bharuchwala
Solved! Go to Solution.
Hi Utsavi,
There are multiple clients that get instantiated (3 to be exact) that all have same priority (8).
In order to allow the clients to round robin, the _time_delay(1); is used to block the current task and allow other client tasks to run.
A simple test it to run the lwmsgq demo with the _time_delay(1);
Terminal results are:
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 1
Client Task 0
B
A
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 2
Client Task 1
Client Task 0
A simple test it to run the lwmsgq demo without the _time_delay(1);
Terminal results are:
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 0
Client Task 0
Client Task 0
A
A
A
Client Task 0
Client Task 0
Client Task 0
A
A
A
Client Task 0
Client Task 0
Client Task 0
Regards,
David
Hi Utsavi,
There are multiple clients that get instantiated (3 to be exact) that all have same priority (8).
In order to allow the clients to round robin, the _time_delay(1); is used to block the current task and allow other client tasks to run.
A simple test it to run the lwmsgq demo with the _time_delay(1);
Terminal results are:
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 1
Client Task 0
B
A
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 2
Client Task 1
Client Task 0
A simple test it to run the lwmsgq demo without the _time_delay(1);
Terminal results are:
Client Task 0
Client Task 1
Client Task 2
A
B
C
Client Task 0
Client Task 0
Client Task 0
A
A
A
Client Task 0
Client Task 0
Client Task 0
A
A
A
Client Task 0
Client Task 0
Client Task 0
Regards,
David
Hi David,
Thnx for the reply. I already have tried this.
I dont know wether I am right or wrong but I have read in MQX User Guide
that the default Scheduling Algorithm in MQX is FIFO and it is priority
based.
Also in MQX Task Templates there is no Time Slice defined in ttl.c file. It
is 0.
So I think it is working on a FIFO.
What I have learnt is, However there is delay to jump from one task to
another, But lwmsg_receive itseft let the task to wait (into sleep mode) so
it will let the other task to run.
I dont know How it is Jumping from one Task to another in FIFO.
Any way thnx again.
On Sat, Feb 14, 2015 at 1:27 AM, David E Seymour <
Hello,
Just my 2 cents on this one, yes by default MQX works on a FIFO. Please check the below image.
In addition, there are some blocked functions (for example _time_delay()). The _time_delay function blocks the calling task. You need to check the
Freescale MQX™ RTOS Reference Manual for more information about the blocked functions.
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------