/*-----------------------------------------------------------*/ portBASE_TYPE xPortStartScheduler( void ) { pxISR pxOriginalTickISR; /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); pxOriginalTickISR = _dos_getvect( portTIMER_INT_NUMBER ); pxOldSwitchISRPlus1 = _dos_getvect( portSWITCH_INT_NUMBER + 1 ); prvSetTickFrequency( configTICK_RATE_HZ ); /* Put our manual switch (yield) function on a known vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); /* Put the old tick on a different interrupt number so we can call it when we want. */ _dos_setvect( portSWITCH_INT_NUMBER + 1, pxOriginalTickISR ); /* The ISR used depends on whether the preemptive or cooperative scheduler is being used. */ #if( configUSE_PREEMPTION == 1 ) { /* Put our tick switch function on the timer interrupt. */ _dos_setvect( portTIMER_INT_NUMBER, prvPreemptiveTick ); } #else { /* We want the timer interrupt to just increment the tick count. */ _dos_setvect( portTIMER_INT_NUMBER, prvNonPreemptiveTick ); } #endif /* Setup a counter that is used to call the DOS interrupt as close to it's original frequency as can be achieved given our chosen tick frequency. */ sDOSTickCounter = portTICKS_PER_DOS_TICK; /* Clean up function if we want to return to DOS. */ if( setjmp( xJumpBuf ) != 0 ) { prvExitFunction(); xSchedulerRunning = pdFALSE; } else { xSchedulerRunning = pdTRUE; /* Kick off the scheduler by setting up the context of the first task. */ portFIRST_CONTEXT(); } return xSchedulerRunning; }
/*-----------------------------------------------------------*/ BaseType_t xPortStartScheduler( void ) { /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); /* Put our manual switch (yield) function on a known vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); #if configUSE_PREEMPTION == 1 { /* Put our tick switch function on the timer interrupt. */ _dos_setvect( portTIMER_INT_NUMBER, prvPreemptiveTick ); } #else { /* We want the timer interrupt to just increment the tick count. */ _dos_setvect( portTIMER_INT_NUMBER, prvNonPreemptiveTick ); } #endif prvSetTickFrequency( configTICK_RATE_HZ ); /* Clean up function if we want to return to DOS. */ if( setjmp( xJumpBuf ) != 0 ) { prvExitFunction(); sSchedulerRunning = pdFALSE; } else { sSchedulerRunning = pdTRUE; /* Kick off the scheduler by setting up the context of the first task. */ portFIRST_CONTEXT(); } return sSchedulerRunning; }