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.

How to create 2 network tasks with NDK?

Dear Sir,

I use NDK with 6437 EVM to implement some ethernet application.

I use the following code to create 2 network tasks, one is for sending video data, one is for receiving command.

    do
    {
        rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr );
    } while( rc > 0 );


static void NetworkOpen()
{
    hTCPServer = TaskCreate (FrameSender, "FrameSender", OS_TASKPRINORM, OS_TASKSTKNORM, 0, 0, 0 );
    hCMDServer = TaskCreate (cmdsrv, "cmdsrv", OS_TASKPRINORM, OS_TASKSTKNORM, 0, 0, 0 );
}

static void NetworkClose()
{
    TaskDestroy (hTCPServer);
    TaskDestroy (hCMDServer);
}

I connect to FrameSender task first, the task will keep sending video data.

Then I connect the cmdsrv task. But when I do this, the FrameSender task will be stoped and won't send video data anymore.

Can you tell me how to create 2 network tasks at the same time? Each task has it's own port, and won't interfere each other.

Thank you!!

Best Regards,

Eric Fang

 

  • My first thought on this is that your tasks would have to be written such that they each block at some point to allow the other to run, since BIOS does not use time slicing if a task of equal or higher priority never blocks than the other lower and equal priority tasks will never get to run. This being said, to debug much further would require more of the content of your actual task functions, however you should be able to use some breakpoints and stepping to determine where this is going wrong, just remember if your task never blocks than nothing else will get to run in your system which can be bad for the stack.

  • Hello: We've had a similar not directly related to network tasks. In our case, we encoded some frames and then we wanted to send them while more frames were being captured and encoded. Once we created the sending task, it would never come to running state. The reason was thatas Bernie suggested, the latter would never preempt the former, provided their priority is the same. Again as Bernie suggested I think you would need to implement round robin scheduling or as we did, invoke TSK_yield manually to force preemption on task. Another interesting possibility would be that instead of forcing preemption a blocking call you'd happen to do preempted the current running task, letting the second one to run. This possibility is in what we are interested now. But we are just on the bggining of our research in this field. Regards, Raúl
  • Hi, Raúl,

    Thanks a lot for your information. I think using TSK_yield is a good idea!

    My code is working now, please refer to the following code:

        hTCPServer = TaskCreate( NetVideoOutTask, "NetVideoOutTask", OS_TASKPRINORM, 0x1400, 0, 0, 0 );
        hCMDServer = TaskCreate( NetCommandTask, "NetCommandTask", OS_TASKPRINORM, 0x1400, 0, 0, 0 );

    I just modify the stack size, and it works!!

    I have to spend some more time to figure out why it works now.

    I have to study more about task and stack in 6437 DSP/BIOS.

    Best Regards,

    Eric Fang