This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Disable preemption

If a function wants to protect itself against reentrancy, is it enough to simply disable HWI? Will that automatically disable SWIs and TSKs as well?

In other words, do I need to do this:

 

    TSK_disable();
    SWI_enable();
    oldmask = HWI_disable();

...... critical section ........

    HWI_restore(oldmask);
    SWI_enable();
    TSK_enable();

 

 

 

 

 

 

 

 

  • Depending on the content of your critical section, HWI_disable() is probably all that is required to protect it from SWI and TSK pre-emption.

    Hwi_disable() blocks asyncronous SWI and TSK pre-emption (ie interrupts that post a SWI or SEM).

    However, if your critical section directly readies a higher priority TSK (ie calls SEM_post()) or posts a SWI (SWI_post()), the critical section WILL be pre-empted.

    If your critical section will be posting SWIs or readying higher priority TSKs, then you will need the additional protection of TSK_disable() and SWI_disable().

     

    Alan DeMars