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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,341 次查看
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

标记 (3)
0 项奖励
1 解答
375 次查看
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 项奖励
1 回复
376 次查看
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 项奖励