Hello,
I want to block few MQX task from another task which is performing some important operation. I studied _task_block api mentioned in MQX RM document but for that i need to add this api in every task which i want to block. Is there is any method to block other task from current running task ??
Ashi Gupta
I want to block few MQX task from another task which is performing some important operation.
No you don't. It is the operating system's job to decide which tasks should run and which should be pre-empted, not the task's. The task should not even know of the existance of other tasks, let alone go fiddling with their state.
If you have a task that needs to run at high priority (thus pre-empting other tasks) while it completes an important function, the task can simply raise its own priority using _task_set_priority(). The task should use _task_get_priority() first to get and remember the initial priority, so it can restore it when the important function is finished.
Hello Ashi Gupta,
I need a little more information about what you need. According you mention I can suggest to use a mutex or semaphore.
A mutex provides mutual exclusion among tasks, when they access a shared resource. Mutexes are strict; that is, a task cannot unlock a mutex, unless it had first locked the mutex.
In addition you can use semaphores to synchronize tasks. You can use a semaphore to guard access to a shared resource, or to implement a producer/consumer-signalling mechanism. Semaphores can be strict or non-strict. There are named and fast semaphores.
You can find mutex and semaphore examples at the path: C:\Freescale\Freescale_MQX_4_2\mqx\examples
In addition you can check the below training documents
Training Class: MQX RTOS v4.1 Basics Training for MQX Beginners
I hope this helps,
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Sol,
I have a functionality of SW download from one of my task. I need to block all other task when SW download starts in order to increase download speed. There is no shared resource used between task. All task will be unblocked as soon as SW download finishes.
Ashi Gupta