This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

6678的NDK代码中的tasksleep()函数问题

Other Parts Discussed in Thread: SYSBIOS

在6678上制作网络通信历程,建立了一个网络数据发送任务TCP_Send(),进入任务后,代码进入一个while(1)循环,在while(1)循环处理函数中加了tasksleep(1)实现任务切换(后续任务还没有建立)。代码架构如下:

TCP_Send()

{

         while(1)

         {

              ………………//数据发送处理

             tasksleep(1);

         }

}

计划使用tasksleep(1)实现任务的切换,但是在测试时发现,该发送任务紧运行一次,且第一次运行可执行到tasksleep函数,但是执行完一次后,该任务不再执行,一直在运行空闲任务,不知道是什么原因导致该任务无法继续运行,求指点

  • 1 是不是您的SYSBIOS中统计tick的timer没有跑起来,检查下寄存器呢?

    2 用SEM-PEND, SEM-POST的机制试试呢

    • The running task becomes Task_Mode_TERMINATED by calling Task_exit(), which is automatically
    called if and when a task returns from its top-level function. After all tasks have returned, the Task
    manager 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; tasks
    can move into this state when they are performing certain I/O operations, awaiting availability of
    some shared resource, or idling.
    • The running task becomes Task_Mode_READY and is preempted whenever some other, higherpriority
    task becomes ready to run. Task_setPri() can cause this type of transition if the priority of the
    current task is no longer the highest in the system. A task can also use Task_yield() to yield to other
    tasks 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 particular
    event: completion of an I/O operation, availability of a shared resource, the elapse of a specified period
    of time, and so forth. By virtue of becoming Task_Mode_READY, this task is scheduled for execution
    according to its priority level; and, of course, this task immediately transitions to the running state if its
    priority is higher than the currently executing task. Task schedules tasks of equal priority on a first-come,
    first-served basis.