yield () in interrupt handler?

1

I have a struct that I have to copy; that does not present any problem, unless during the copy activates an interruption, and the handle function modify the data of that struct .

In principle, there would be no problem. We protect data through calls to

atomic_flag_test_and_set( );

If we were in a multithread environment, we could do a thrd_yield( ); , ceding the CPU to another process as long as we can not access the protected data.

But, what if we are in an interrupt handler? Here we can not do a thrd_yield( );

The question, then, is the following:

  

How to wait, within an interruption management function, to   that a resource is free, without returning to re-launch the interruption?

    
asked by Trauma 16.12.2016 в 14:33
source

1 answer

3
  

How to wait, within an interruption management function, for a resource to be free, without relaunching the interruption?

You do not need to wait for anything, if the resource is busy, paste a message (in a queue created for that purpose) and in the next pass (either of the interruption or of the process) you apply the "glued" changes to struct before performing the shift operation.

This technique is widely used in telecommunications and is called postpone . Where the execution of certain tasks is postponed until the conditions are met. It basically serves to synchronize orthogonal states. That is, to handle all the transitions that are only possible from a particular state.

    
answered by 16.12.2016 / 15:00
source