/*test case:test the reaction of the system called with an activation of a task*/ static void test_callback2_instance(void) { SCHEDULING_CHECK_STEP(6); SuspendAllInterrupts(); SuspendAllInterrupts(); SuspendAllInterrupts(); tpl_send_it1(); ResumeAllInterrupts(); ResumeAllInterrupts(); ResumeAllInterrupts(); SCHEDULING_CHECK_STEP(7); }
/*test case:test the reaction of the system called with an activation of a isr*/ static void test_pretask_instance11(void) { SCHEDULING_CHECK_STEP(13); tpl_send_it1(); SuspendAllInterrupts(); tpl_send_it1(); ResumeAllInterrupts(); }
/*test case:test the reaction of the system called with an activation of a isr*/ static void test_pretask_instance2(void) { SCHEDULING_CHECK_STEP(2); sendSoftwareIt(0, SOFT_IRQ0); SuspendAllInterrupts(); sendSoftwareIt(0, SOFT_IRQ0); ResumeAllInterrupts(); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_callback1_instance(void) { SCHEDULING_CHECK_STEP(2); SuspendAllInterrupts(); ResumeAllInterrupts(); sendSoftwareIt(0, SOFT_IRQ0); SCHEDULING_CHECK_STEP(3); }
/*test case:test the reaction of the system called with an activation of a isr*/ static void test_error_instance(void) { int err_instance = posttask_instance/2; int test_start = err_instance * 4; SCHEDULING_CHECK_STEP(test_start + 2); sendSoftwareIt(0, SOFT_IRQ0); SuspendAllInterrupts(); sendSoftwareIt(0, SOFT_IRQ0); ResumeAllInterrupts(); }
//////////////////////////////////////////////////////////// // Function name: Schedule // Description: Schedule a task queue to run // Parameter: none // Return value: Whether the operation succeeded // Function calls: none // //////////////////////////////////////////////////////////// StatusType Schedule(void) { //static sint8_least tmpMaxTask = 1; TCB_Type *tmpTCB; #ifdef _OS1_DEBUG_ for(tmpIndex = 0; tmpIndex < OS_MAX_RESOURCE; tmpIndex++) { if(Os_Res_Owner[tmpIndex] == Os_TCBCurr->taskID) { //Resource not released return E_OS_RESOURCE; } } if(InterruptState == TRUE) { //Call in interrupt return E_OS_CALLEVEL; } #endif //没有合适的则运行优先级最低的任务 Os_TCBReady = &Os_TCB[0]; for(tmpTCB=&Os_TCB[OS_MAX_TASK]; tmpTCB->taskID>0; tmpTCB--) { if(tmpTCB->state == READY) { tmpTCB->state = RUNNING; //Os_TCBCurr = &Os_TCB[tmpIndex]; Os_TCBReady = tmpTCB; break; } } //当前任务正在进行,触发软中断进行任务切换 if(Os_TCBCurr->state == RUNNING) { Os_TCBCurr->state = READY; Os_TCBCurr=Os_TCBReady; Os_TCBReady->state = RUNNING; SuspendAllInterrupts(); OS_TASK_SW(); ResumeAllInterrupts(); } return E_OK; }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { AlarmBaseType AlarmBaseType_inst_1; EventMaskType EventMaskType_inst_1; StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19; TaskStateType TaskStateType_inst_1; TaskType TaskType_inst_1; TickType TickType_inst_1; SCHEDULING_CHECK_STEP(1); SCHEDULING_CHECK_STEP(2); SuspendAllInterrupts(); SCHEDULING_CHECK_INIT(3); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_DISABLEDINT, result_inst_2); SCHEDULING_CHECK_INIT(5); result_inst_3 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_DISABLEDINT, result_inst_3); SCHEDULING_CHECK_INIT(7); result_inst_4 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_DISABLEDINT, result_inst_4); SCHEDULING_CHECK_INIT(9); result_inst_5 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_DISABLEDINT, result_inst_5); SCHEDULING_CHECK_INIT(11); result_inst_6 = GetTaskID(&TaskType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_DISABLEDINT, result_inst_6); SCHEDULING_CHECK_INIT(13); result_inst_7 = GetTaskState(t2, &TaskStateType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OS_DISABLEDINT, result_inst_7); SCHEDULING_CHECK_INIT(15); result_inst_8 = GetResource(Resource1); SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OS_DISABLEDINT, result_inst_8); SCHEDULING_CHECK_INIT(17); result_inst_9 = ReleaseResource(Resource1); SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OS_DISABLEDINT, result_inst_9); SCHEDULING_CHECK_INIT(19); result_inst_10 = SetEvent(t2, Event1); SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OS_DISABLEDINT, result_inst_10); SCHEDULING_CHECK_INIT(21); result_inst_11 = ClearEvent(Event1); SCHEDULING_CHECK_AND_EQUAL_INT(22,E_OS_DISABLEDINT, result_inst_11); SCHEDULING_CHECK_INIT(23); result_inst_12 = GetEvent(t2, &EventMaskType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OS_DISABLEDINT, result_inst_12); SCHEDULING_CHECK_INIT(25); result_inst_13 = WaitEvent(Event1); SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OS_DISABLEDINT, result_inst_13); SCHEDULING_CHECK_INIT(27); result_inst_14 = GetAlarmBase(Alarm1, &AlarmBaseType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OS_DISABLEDINT, result_inst_14); SCHEDULING_CHECK_INIT(29); result_inst_15 = GetAlarm(Alarm1, &TickType_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_DISABLEDINT, result_inst_15); SCHEDULING_CHECK_INIT(31); result_inst_16 = SetRelAlarm(Alarm1, 1, 0); SCHEDULING_CHECK_AND_EQUAL_INT(32,E_OS_DISABLEDINT, result_inst_16); SCHEDULING_CHECK_INIT(33); result_inst_17 = SetAbsAlarm(Alarm1, 1, 0); SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OS_DISABLEDINT, result_inst_17); SCHEDULING_CHECK_INIT(35); result_inst_18 = CancelAlarm(Alarm1); SCHEDULING_CHECK_AND_EQUAL_INT(36,E_OS_DISABLEDINT, result_inst_18); SCHEDULING_CHECK_INIT(37); result_inst_19 = GetActiveApplicationMode(); SCHEDULING_CHECK_AND_EQUAL_INT(38,OSDEFAULTAPPMODE, result_inst_19); SCHEDULING_CHECK_STEP(39); ResumeAllInterrupts(); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3; SCHEDULING_CHECK_STEP(1); SuspendAllInterrupts(); SCHEDULING_CHECK_INIT(2); result_inst_1 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_DISABLEDINT, result_inst_1); SCHEDULING_CHECK_STEP(3); sendSoftwareIt(0, SOFT_IRQ0); SCHEDULING_CHECK_STEP(4); ResumeOSInterrupts(); SCHEDULING_CHECK_STEP(5); EnableAllInterrupts(); SCHEDULING_CHECK_STEP(6); ResumeAllInterrupts(); SCHEDULING_CHECK_STEP(8); SuspendOSInterrupts(); SCHEDULING_CHECK_INIT(9); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OS_DISABLEDINT, result_inst_2); SCHEDULING_CHECK_STEP(10); sendSoftwareIt(0, SOFT_IRQ0); SCHEDULING_CHECK_STEP(11); ResumeAllInterrupts(); SCHEDULING_CHECK_STEP(12); EnableAllInterrupts(); SCHEDULING_CHECK_STEP(13); DisableAllInterrupts(); SCHEDULING_CHECK_STEP(14); EnableAllInterrupts(); SCHEDULING_CHECK_STEP(15); ResumeOSInterrupts(); SCHEDULING_CHECK_STEP(17); DisableAllInterrupts(); SCHEDULING_CHECK_INIT(18); result_inst_3 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OS_DISABLEDINT, result_inst_3); SCHEDULING_CHECK_STEP(19); sendSoftwareIt(0, SOFT_IRQ0); SCHEDULING_CHECK_STEP(20); ResumeAllInterrupts(); SCHEDULING_CHECK_STEP(21); ResumeOSInterrupts(); SCHEDULING_CHECK_STEP(22); EnableAllInterrupts(); SCHEDULING_CHECK_STEP(24); }