How to block one task from another task

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

How to block one task from another task

1,760 次查看
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

标记 (2)
0 项奖励
回复
3 回复数

1,050 次查看
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 项奖励
回复

1,050 次查看
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 项奖励
回复

1,050 次查看
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 项奖励
回复