How do I organize AC power synchronous activity?

I want to use a Nano to perform a control function and communication. I have an input that is high during the positive half of the AC cycle and low during the negative half of the AC cycle (50 or 60 Hz.) It transitions very close to the zero crossing (less than 100 us). I want to optionally turn on an I/O bit very close after the zero crossing.

A change mode interrupt on pin 2 at zero level seems ideal and gets in and out of ISR fast with little or no perturbation of other interrupts.

In addition I want to do some processing that takes about 1 ms every half cycle. When in the half cycle it is performed is not critical but it is critical that it always be completed within the half cycle (about 8.3 ms).

Finally I am communicating with I2C and a console. These actions can be carried out over seconds and can be interrupted.

I could tack the processing onto the ISR but my concern is that with interrupts disabled for up to a ms that it might interfere with any other interrupt activity or communication that is going on. I could re-enable interrupts in the ISR after the first critical action but my concern is that if some other source happens to interrupt there could be two problems. The work would not get done in the half cycle and there might be recursion that would screw up the ISR. The recursion might be worse than failure to complete the ms of processing.

Do you have a suggestion how I might otherwise organize this? I have read Mr. Gammon's article and plan to start with a single ISR to do both tasks and a main loop to do the communication and I2C.

I have previously done all of these without combining them.

I could tack the processing onto the ISR but my concern is that with interrupts disabled for up to a ms that it might interfere with any other interrupt activity or communication that is going on

Yes the real time clock will loose time and serial reception might loose bytes. If you want to avoid this then the ISR has to be shorter that these other interrupting processes.

you could adopt a system of flags where the ISR kicks off an action and sets a flag and returns then your main loop sees the flag, finishes the action and resets thee flag

Or you could enable interrupts inside your ISR.

In addition I want to do some processing that takes about 1 ms every half cycle.

With a 16MHz Arduino, there are 16K processor cycles in 1ms. What "processing" takes that long, and how have you benchmarked the time taken?

I assume that you want to use the AC frequency as an accurate oscillator, at 50 Hz. or 60 Hz. If you you just run your AC through a diode and a voltage divider, you could get a positive only signal which rose to 5 v. once each AC cycle. Of course mixing mains and 5 v. on one board is risky.

So setup an interrupt for RISING, and in the interrupt just used a volatile unsigned long, say "clockTick", and in the interrupt, only one line of code, "clockTick++;". That takes very little time to execute, and then you can derive whatever other timing intervals you need from clockTick.