void ISR_auxTimer()
{
    IRQstackOverflowCheck();
    miosix::Scheduler::IRQfindNextThread();//If the kernel is running, preempt
    if(miosix::kernel_running!=0) miosix::tick_skew=true;
    TIM3->SR=0;
}
void ISR_yield()
{
    #ifdef WITH_PROCESSES
    // WARNING: Temporary fix. Rationale:
    // This fix is intended to avoid kernel or process faulting due to
    // another process actions. Consider the case in which a process statically
    // allocates a big array such that there is no space left for saving
    // context data. If the process issues a system call, in the following
    // interrupt the context is saved, but since there is no memory available
    // for all the context data, a mem manage interrupt is set to 'pending'. Then,
    // a fake syscall is issued, based on the value read on the stack (which
    // the process hasn't set due to the memory fault and is likely to be 0);
    // this syscall is usually a yield (due to the value of 0 above),
    // which can cause the scheduling of the kernel thread. At this point,
    // the pending mem fault is issued from the kernel thread, causing the
    // kernel fault and reboot. This is caused by the mem fault interrupt
    // having less priority of the other interrupts.
    // This fix checks if there is a mem fault interrupt pending, and, if so,
    // it clears it and returns before calling the previously mentioned fake
    // syscall.
    if(SCB->SHCSR & (1<<13))
    {
        if(miosix::Thread::IRQreportFault(miosix_private::FaultData(
            MP,0,0)))
        {
            SCB->SHCSR &= ~(1<<13); //Clear MEMFAULTPENDED bit
            return;
        }
    }
    #endif // WITH_PROCESSES
    IRQstackOverflowCheck();
    
    #ifdef WITH_PROCESSES
    //If processes are enabled, check the content of r3. If zero then it
    //it is a simple yield, otherwise handle the syscall
    //Note that it is required to use ctxsave and not cur->ctxsave because
    //at this time we do not know if the active context is user or kernel
    unsigned int threadSp=ctxsave[0];
    unsigned int *processStack=reinterpret_cast<unsigned int*>(threadSp);
    if(processStack[3]!=miosix::SYS_YIELD)
        miosix::Thread::IRQhandleSvc(processStack[3]);
    else miosix::Scheduler::IRQfindNextThread();
    #else //WITH_PROCESSES
    miosix::Scheduler::IRQfindNextThread();
    #endif //WITH_PROCESSES
}
void ISR_yield()
{
    IRQstackOverflowCheck();
    miosix::Scheduler::IRQfindNextThread();
}