The registered handler runs in the context of the spawned task. As it exists right now, it is running at default priority. That means that it can task switch during the handler. The handler does however call taskSafe() before calling the handler, which means that if disable() is called while the handler is running, the disable call will block until the handler returns.
The task for the handler is spawned in the call to tInterruptManager::enable() and the task is deleted in the call to tInterruptManager::disable().
It certainly doesn't help that the destructor for Notifier doesn't set talarm and manager to NULL. If it were to run again, the objects are deleted, but not NULL so they aren't created when the constructor runs again. This is what you are seeing.
Another problem is that the manager and talarm objects are not reference counted so if you create 2 Notifiers, then delete one, the static variables are deleted and the remaining Notifier is broken.
Another problem is that the Notifier uses global variables. It looks like it would be far more appropriate for it to hold the tAlarm and tInterruptManager objects as static variables in the Notifier class.
The Semaphore also should be created on first use instead of statically initialized and should be a static member of the class.
Also m_head is defined in the class and never used, but timerQueueHead is defined globally and is used instead.
It seems this class needs some work.



Reply With Quote
or there's another issue here to be discovered. I'll be looking at it more tonight, armed with the knowledge you've given.