|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2009-5-22 20:10:40
|
显示全部楼层
有想法,并尝试过,不知道如何解释这个现象:
有3个task,每个控制一LED灯闪动,设置其优先级都是1。 如下:
//PF2
STATUS TSK_Led1(STATUS ucEvent)
{
PORTF |= (1<<PF2);
Delay1();
PORTF &= ~(1<<PF2);
Delay1();
PORTF |= (1<<PF2);
Delay1();
PORTF &= ~(1<<PF2);
Delay1();
PORTF |= (1<<PF2);
return SYS_OK;
}
//PF1
STATUS TSK_Led2(STATUS ucEvent)
{
PORTF |= (1<<PF1);
Delay1();
PORTF &= ~(1<<PF1);
Delay1();
PORTF |= (1<<PF1);
Delay1();
PORTF &= ~(1<<PF1);
Delay1();
PORTF |= (1<<PF1);
return SYS_OK;
}
//PD4
STATUS TSK_Led3(STATUS ucEvent)
{
PORTD |= (1<<PD4);
Delay1();
PORTD &= ~(1<<PD4);
Delay1();
PORTD |= (1<<PD4);
Delay1();
PORTD &= ~(1<<PD4);
Delay1();
PORTD |= (1<<PD4);
return SYS_OK;
}
//--------------------------------------------------------------------------------
/* Task initialisation table must be properly initialized. In this example
* all task have
equal priority and will be scheduled in round robin fashion.
*/
task_entry_t uSmartXTaskTable[] = {
{&TSK_Led1, &TSK_LED1, 1, "LED1"},
{&TSK_Led2, &TSK_LED2, 1, "LED2"},
{&TSK_Led3, &TSK_LED3, 1, "LDE3"},
{0,0,0,""}
};
但是实际上现象:有时只有LED1闪动,有时都根本不闪。
不是在调度函数那里运行一个任务之后,下次调换才运行下一个任务吗?这种情况如何解释? |
|