Shared resource between task and ISR

If both the task and the ISR need to modify the variable then a critical section is your best bet. If you can design your application so that the ISR only writes and the task only consumes then you would be able to use fromISR APIs (placing signals into a queue for example).