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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
2,206件の閲覧回数
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 解決策
1,240件の閲覧回数
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 返信
1,241件の閲覧回数
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 件の賞賛
返信