在6678上制作网络通信历程,建立了一个网络数据发送任务TCP_Send(),进入任务后,代码进入一个while(1)循环,在while(1)循环处理函数中加了tasksleep(1)实现任务切换(后续任务还没有建立)。代码架构如下:
TCP_Send()
{
while(1)
{
………………//数据发送处理
tasksleep(1);
}
}
计划使用tasksleep(1)实现任务的切换,但是在测试时发现,该发送任务紧运行一次,且第一次运行可执行到tasksleep函数,但是执行完一次后,该任务不再执行,一直在运行空闲任务,不知道是什么原因导致该任务无法继续运行,求指点
Thomas Yang1:
1 是不是您的SYSBIOS中统计tick的timer没有跑起来,检查下寄存器呢?
2 用SEM-PEND, SEM-POST的机制试试呢
• The running task becomes Task_Mode_TERMINATED by calling Task_exit(), which is automaticallycalled if and when a task returns from its top-level function. After all tasks have returned, the Taskmanager terminates program execution by calling System_exit() with a status code of 0.• The running task becomes Task_Mode_BLOCKED when it calls a function (for example,Semaphore_pend() or Task_sleep() ) that causes the current task to suspend its execution; taskscan move into this state when they are performing certain I/O operations, awaiting availability ofsome shared resource, or idling.• The running task becomes Task_Mode_READY and is preempted whenever some other, higherprioritytask becomes ready to run. Task_setPri() can cause this type of transition if the priority of thecurrent task is no longer the highest in the system. A task can also use Task_yield() to yield to othertasks with the same priority. A task that yields becomes ready to run.
A task that is currently Task_Mode_BLOCKED transitions to the ready state in response to a particularevent: completion of an I/O operation, availability of a shared resource, the elapse of a specified periodof time, and so forth. By virtue of becoming Task_Mode_READY, this task is scheduled for executionaccording to its priority level; and, of course, this task immediately transitions to the running state if itspriority is higher than the currently executing task. Task schedules tasks of equal priority on a first-come,first-served basis.