Unblocking a Task that has blocked itself by calling _task_block()

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

Unblocking a Task that has blocked itself by calling _task_block()

Jump to solution
1,333 Views
Tim562
Senior Contributor I

Hi All,

I'm trying to get a service Task to run periodically (at priority 9), so I've created the task in my main task (priority 10) like this:

_task_id tiNewTaskID;

tiNewTaskID= _task_create_blocked(0, gcFSERVE_TASK, 0);

Then, in a timer ISR I unblock the task and make it ready like this:

_task_ready( _task_get_td(tiNewTaskID) );

Once the service task completes it blocks again like this:

_task_block();

The problem I'm having is that the service task only unblocks and runs once (the first time the timer ISR sets it ready). Once the service Task calls _task_block() and blocks itself it never runs again. Am I doing something wrong here? Perhaps this isn't the proper way to have a task run periodically by a timer ISR? By the way, I can make this work if I create a new Task each time the timer ISR fires and have the service Task destroy itself when it's finished. It just seems like the wrong way to go about it. The processor being used is the MPC-5125 with MQX 3.8.0 RTOS. Any ideas? Thanks!

~Tim

Tags (3)
0 Kudos
1 Solution
367 Views
Tim562
Senior Contributor I

Well, as usual, the problem was not what it appeared to be (not with a task at all). The service function call that represents the entry point for the MQX service task was written to return after doing what it needed to do! Since the task function had completed and exited there was no task to unblock (dooouh... ). I feel pretty silly but the obvious fix was just to have the service function do it's chores in an endless while() loop that blocks at the end of the loop. Some days your the bat and some days.....

~Tim

View solution in original post

0 Kudos
1 Reply
368 Views
Tim562
Senior Contributor I

Well, as usual, the problem was not what it appeared to be (not with a task at all). The service function call that represents the entry point for the MQX service task was written to return after doing what it needed to do! Since the task function had completed and exited there was no task to unblock (dooouh... ). I feel pretty silly but the obvious fix was just to have the service function do it's chores in an endless while() loop that blocks at the end of the loop. Some days your the bat and some days.....

~Tim

0 Kudos