How to create a ENTER_CRITICAL_SECTION and EXIT_CRITICAL_SECTION in MQX?

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

How to create a ENTER_CRITICAL_SECTION and EXIT_CRITICAL_SECTION in MQX?

Jump to solution
2,549 Views
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 Solution
1,130 Views
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

 

 

View solution in original post

0 Kudos
3 Replies
1,130 Views
c0170
Senior Contributor III

Hi mikedwn,

 

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

 

 

Regards,

MartinK

0 Kudos
1,130 Views
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 Kudos
1,131 Views
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 Kudos