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.

threads' priority when using NDK



I set two static threads in BIOS, names of which are StackTest and mycalcu(priorities are both 5). In the StackTest, I setup a dynamic task mytcp(the code is: hData=TaskCreate(mytcp,"mytcp",OS_TASKPRINORM,0X1400,0,0,0);).

I hope the executive order is: StackTest, mytcp and mycalcu. But when the program is running, the executive order is: StackTest, mycalcu and mytcp. Though I can adjust the executive order to my hope by SEM(SEM_ipost,SEM_pend), but why there is no SEM, mycalcu will execute after StackTest. Because I think mytcp is set in StackTest, so it should execute after StackTest. Does somebody know the reason?

  • Are you using "TaskCreate()" API in your code?   This API is part of the NDK's OS abstraction layer.   You should probably use DSP/BIOS 5.x's TSK_create() (or Task_create() if you are using SYS/BIOS 6.x).    You can set the attrs.priority field to specify the priority of your thread.    Threads of equal priority (you speciify 5 above) will execute in the order that they are created.  If you want one thread to run before another, you should either create it first, or create it with a higher priority.

  • Karl Wechsler said:

    Are you using "TaskCreate()" API in your code?   This API is part of the NDK's OS abstraction layer.  

    Yes, I use "TaskCreate()" API, because I use NDK  to realize net connection.

    When the net is initialized, I use function to start net connection. The code is:

    do

    {

           rc=NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr);

    }while(rc>0);

    In the function of NetworkOpen(), I set up mytcp task as follows:

    void NetworkOpen()

    {

           hData=TaskCreate( mytcp, "mytcp", OS_TASKPRINORM, 0X1400, 0, 0, 0);

    }

     I thought when StackTest is finished, mytcp will execute, but the truth is not. Then I modify the priority of mytcp using OS_TASKPRIHIGH instead of OS_TASKPRINORM, but mytcp still doesn't execute after StackTest.