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,565件の閲覧回数
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,146件の閲覧回数
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,146件の閲覧回数
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,146件の閲覧回数
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,147件の閲覧回数
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 件の賞賛