-1

Now I'm learn freeRTOS api " taskENTER_CRITICAL()" in FreeRTOS V9.0.0 reference manual. I find such description for this API: "FreeRTOS API functions must not be called from within a critical section" Why? why we can't call freertos api whthin a critical section? like below show:

taskENTER_CRITICAL();
do_something..
xQueueReceive();  // ?? why can't call this api within this critical setction ??
taskEXIT_CRITICAL();

Hope response from anyone, Thanks!

BR//David Wang

A.R.C.
  • 910
  • 11
  • 22
  • Well, I don't know any details about freeRTOS but it sounds like when they say a critical section, they really mean a CRITICAL section. Like interrupt handlers keep it short. LIke 200 CPU instructions short. – Zan Lynx Dec 13 '18 at 06:22
  • Thanks! But if I call some FreeRTOS system call within CRITICAL section, what will happen? system crash or system hang or ... ? – David Wang Dec 14 '18 at 02:55
  • @DavidWang Try it yourself. – 0___________ Jan 11 '19 at 11:23

1 Answers1

0

Interrups are avoided in code written in critical section. xQueueReceive() also working by interrups that is main reason.

SG92
  • 76
  • 9