How can I correctly setup attachInterrupt() in this sketch?

Those would be the lines that go in the critical section.