Deferred Procedure Call & interrupts

Hi,
I am writing some code to perform communiction through 2 serial lines at the same time using interrupts. When in an ISR, other interrupts are blocked, so I need to leave the ISR as soon as possible.

I now have a (large) task to perform but want to start it after leaving the ISR.
In Windows there was the possibility to write a DPC (deferred procudure call) which changes the stack so it would first do this DPC procedure and when the procedure finishes, return to the original code which was left by the interrupt.

Is this possible with Arduino too?

Best regards

Why ISR for serial communication? See Robin's updatedSerial Input Basics. It can easily be adapted for multiple serial ports.

Break your large task into smaller chunks and it will not block so the data on the second serial port can also be received and processed.

Suitability of interrupts for this application notwithstanding, generally speaking, you want to quickly do what needs to be done in the ISR and then set a flag. Pick up that flag and do the time-consuming processing as part of your non-ISR code:

volatile bool doLargeTask = false;
void myISR(void);

void setup() {
  // Attach interrupts and do other stuff here

}

void loop() {
  // Do your main processing here

  if (doLargeTask) {
    noInterrupts();
    doLargeTask = false;
    interrupts();
    // Do the time-consuming task here
  }

  // Continue with main processing

}

void myISR() {
  // Quickly service hardware, etc here
  doLargeTask = true;
}
    noInterrupts();
    doLargeTask = false;
    interrupts();

It is not necessary to disable interrupts to perform an atomic operation.

PaulS:
It is not necessary to disable interrupts to perform an atomic operation.

True, toggling interrupts is the generic procedure. Sometimes you might want to grab / reset a counter or manipulate other volatile variables.