Task Issue

ambrish30 wrote on Friday, April 26, 2019:

Hi,
I have created two tasks for MPLAB MZ for PIC32. But after completing task1, it is not coming back to task2 or task1. Can you please suggest me the way.

Regards

richarddamon wrote on Friday, April 26, 2019:

You don’t describe what you are doing, but when a task ‘completes’, it shouldn’t ‘return’, but needs to delete itself. A task that actually returns may end up crashing the system, as many ports don’t setup a return address for the task to return to.

ambrish30 wrote on Monday, May 06, 2019:

Hi Richard,
Thanks for your quick response.
I have two tasks, these are very simple task, Just priting “Task1” in task1 and “Task2” in task2. But when i run the code i get Task2 as printed, after that compiler is not coming back to higher priority task.
Can you please suggest me where to setup the return address?

ambrish30 wrote on Monday, May 06, 2019:

rtel wrote on Monday, May 06, 2019:

By ‘compiler is not coming back’ I assume you mean the processor is not
executing the other task. How do you know the processor is only
executing one task? Normally in these situations the cause of the
problem is the print function - is that thread safe if you are calling
it from two tasks? Best starting point is to remove the print
statements, place a break point in each task, then see if both break
points get hit - proving both tasks are running. Also, you still don’t
show the structure of your tasks so you haven’t given Richard D the
information he is looking for - which is to say - are you trying to
return or in any way exit the function that is implementing the tasks?