How to block one task from another task

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

How to block one task from another task

1,685 Views
ashigupta1990
Contributor I

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

Tags (2)
0 Kudos
Reply
3 Replies

975 Views
matthewkendall
Contributor V
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.

0 Kudos
Reply

975 Views
soledad
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

975 Views
ashigupta1990
Contributor I

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

0 Kudos
Reply