leOS - a simple taskmanager/scheduler

I wrote a beta version of leOS2.
The release 2.0.9x introduces the ability to pass to leOS2 a param during initialization that instructs the class to set the WDT to work in interrupt mode only or in interrupt+system reset mode.
The first mode is the mode actually used by leOS2: when the WatchDog timer expires, an interrupt is raised, then it's intercepted by the corresponding ISR and the scheduler is run.
Using the second me we can use a particular way of working of the WDT: the first time that its timer expires it raises an interrupt, then it clears the WDIE flag so that the next timeout it will reset the MCU. But if in the ISR routine we set again the WDIE flag to "1", at the next WDT timeout we will get another interrupt, not a system reset. And so on.

Starting from this, I thinked how to use this trick. So, using a suggestion of the user lesto, I created the ISR routine interruptable using the param "ISR_NOBLOCK" so that it can be halted during its execution by another call made by the WDT. Then I put a flag to check if a task is running: if it is, a decrement a counter. This counter contains the param passed by the user, that I use as a timeout befor the reset. While I wait that the task has completed its execution, I decrement the counter and set to "1" the WDIE bit: if the counter reaches zero before the task has completed its work the scheduler assumes that it freezed during execution, so the scheduler didn't set the WDIE to 1 anymore and the WDT will reset the microcontroller.

In this manner I can create non-freezable sketches using only ony peripheral.