Yes, this is type of operation for which will be better to use some synchronization object instead of task_block()/task_ready() functions.
In case of interrupt it is better mark somewhere that some event happened instead of execution of direct action.
If your application is based on 1:1 flow control (1 interrupt: 1 transfer: 1 interrupt: and so on) you can use for example simple lwevent with LWEVENT_AUTO_CLEAR option. In interrupt you will just post event (let say that it is value change 0 ->1).
If some task, waits for this event it will clear this event (1 ->0) and task will become active/ready (depends on priority). This all happens in protected mode inside scheduler.
If more interrupts comes and there isn’t waiting task for event, nothing happened (event will be already set 1 ->1). If after that task will execute lwevent_wait() function, task will continue without stop because event was already set prior we wait for them (event will be cleared in this ).
If you want implement some buffer for data and occurrence of interrupts do not need exactly fits to transfers, semaphore or rather lightweight semaphore will be better choice. This object could be used as counting – post will increase counter, wait will decrease counter. When counter=0 task will became blocked until next post…
Typical solution is that tasks running in endless loops. However if task returns, it will be destroyed and you have to call task_create (or similar function) for execute this task again.
I would like to recommend do not use this concept since it could be sometimes dangerous. Task_destroy is asynchronous operation and it could work correctly only under specific conditions.
I would like to recommend this link to Essentials of MQX RTOS Application Development:
http://www.freescale.com/webapp/sps/site/training_information.jsp?code=WBT_MQX_RTOS_COURSE
It contains a lot of useful information and I hope it helps you
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------