How to create a ENTER_CRITICAL_SECTION and EXIT_CRITICAL_SECTION in MQX?

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

How to create a ENTER_CRITICAL_SECTION and EXIT_CRITICAL_SECTION in MQX?

跳至解决方案
2,936 次查看
mikedwn
Contributor II

Hello:

 

I am trying to port existing code that have macro called "ENTER_CRITICAL_SECTION()" and "EXIT_CRITICAL_SECTION()". I look into the MQX document that doesn't have critical section API.

 

Does anyone know how to create a MQX called that service "ENTER_CRITICAL_SECTION()" and "EXIT_CRITICAL_SECTION()"?

 

Thank You

Mike

1 解答
1,517 次查看
MarkP_
Contributor V

In MQX3.8:

For short code block protection:

_int_disable()

_int_enable()

 

For other protection lightweigth semaphore:

_lwsem_create()

_lwsem_wait()

_lwsem_post()

 

Disabling task context switch but allows interrupts to run

_task_stop_preemption()

_task_start_preemption()

 

~Mark

 

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,517 次查看
c0170
Senior Contributor III

Hi mikedwn,

 

can you write us an important detail what did your code protect with critical section ?

 

 

Regards,

MartinK

0 项奖励
回复
1,517 次查看
monXii
Contributor III

i know this critical section from FreeRTOS ..

 

.. lock the os and just execute code like without os .. no task switching, and so on ..

0 项奖励
回复
1,518 次查看
MarkP_
Contributor V

In MQX3.8:

For short code block protection:

_int_disable()

_int_enable()

 

For other protection lightweigth semaphore:

_lwsem_create()

_lwsem_wait()

_lwsem_post()

 

Disabling task context switch but allows interrupts to run

_task_stop_preemption()

_task_start_preemption()

 

~Mark

 

 

0 项奖励
回复