cancel
Showing results for 
Search instead for 
Did you mean: 

How are interrupts handled when program execution is in critical region?

noobmaster69
Associate III

Below is the code of Sequencer function to register task.

void UTIL_SEQ_RegTask(UTIL_SEQ_bm_t TaskId_bm, uint32_t Flags, void (*Task)( void ))
{
  UTIL_SEQ_ENTER_CRITICAL_SECTION();
 
  TaskCb[SEQ_BitPosition(TaskId_bm)] = Task;
 
  UTIL_SEQ_EXIT_CRITICAL_SECTION();
 
  return;
}

Here, when the program execution is in critical region, i.e. when line 5 is being executed, what will happen if any interrupt occurs? Since, in critical region, interrupts are disabled, if any interrupts occur, then will those interrupts will be serviced after exiting the critical region or those interrupts will be missed?

How do you guys handle this situation wherein you are in critical region and you get interrupt?

Regards,

noobmaster69

2 REPLIES 2
KnarfB
Principal III

If a new interrupt arrives while it is disabled (e.g. in a critical section), the interrupt becomes pending. As soon as the interrupt is later enabled, it will be handled. Same for more than one different pending interrupt, all will be handled afterwards in prio order. The pending bit acts as a queue of depth 1. So, if the same interrupt arrives more than once during a critical section, it is only executed once afterwards, the other instances of the same interrupt are lost.

See "The Definitive Guide to the ARM Cortex..." books by Yoseph Yiu or the ARM Cortex... Prog Manuals.

hth

KnarfB

Okay thanks for the reply. Will check that.

Regards,

noobmaster69