1 of 1 people found this helpful
Q1、When the priorities are set different, why only task1 run correctly when the delay time is 1ms , but both tasks run when the delay time is longer?
A: Seems the reason is: The execute time of code: printf( "This thread 111111\r\n" ) ; Plus the thread switch time is longer than 1ms and less than 2ms. So the situation: task1: 7, task2:8, delay(1ms)'s switch logic is: Switch to Task1->Printf("This thread 1111111\r\n")-> Suspend Task1-1ms->Switch to Task 2->Printf("This thread 22222\r\n"); but this is not execute completely（Like only print "T"）as the Task1 is triggered after 1ms-> Switch to Task 1-> Printf("This thread 1111111\r\n"). Try to use this printf("1\n\r"); or larger the delay time.
Q2. When I replace wiced_rtos_delay_milliseconds(1) with wiced_rtos_delay_microseconds(1000) or even wiced_rtos_delay_microseconds(1000000) , only the task with higher priority run. Why does not the wiced_rtos_delay_microseconds() function cause task scheduling？
A: wiced_rtos_delay_miliseconds include the tx_thread_sleep which can set the task to suspend but wiced_rtos_delay_microseconds had not include the tx_thread_sleep. Say: the wiced_rtos_delay_microseconds only include the delay function not include the RTOS suspend function.