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.

Issues with task priorities in NDK

Adding this post from the C6000 MC forum.

http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/317482/1109526.aspx

regards -emil

  • Hi,

    A few things to check:
    1.  What Tasks are in your system and what are their priorities relative to each other?  A ROV screen shot when the failure occurs would be nice!

    2.  Make sure the dummy for-loop does not get optimized out.  You can do this by having a function call in the for-loop or a volatile variable.  Basically, make sure that you are actually spending some cycles spinning.

    Judah

  • Thanks Judah, here is their response:

    I do have code in the for loop so it's not optimized out. I also have a printf statement after each message is sent so I can see the delay loop is taking effect.

    I've attached the ROV screenshots in both the working case (TxDataTask is priority 1) and not working (TxDataTask is priority 2). I can see that the NetworkTask priority has dropped to 1. Does the task normally change priorities on the fly like that?

    Working Case ROV - Tasks snapshot

    Not-Working Case ROV - Tasks Snapshot:

  • I know that the NetworkTask priority does change on the fly.  The NetworkTask priorty being 1 seems like a problem to me.  I don't know the details of the NDK and my colleague who does know is out of the office today.  I will have to get back to you.

  • It looks like there's a priority inversion occurring.

  • Johannes said:
    Not-Working Case ROV - Tasks Snapshot:

    Has the stack been shut down at this point? (i.e. has NC_NetStart() returned?

    The only place where the priority would drop to 2 is in the following code, which happens after the NetScheduler exits and the stack shut down and clean up code runs:

        TaskSetPri( TaskSelf(), OS_SCHEDULER_LOWPRI );

    Steve

  • Stever, here is the latest findings:

    No – the stack has not been shutdown. I was able to figure one thing out – the initial priority of the task seems to have an effect.

    I have TaskCreate(&NetworkTask, “NetworkTask”, PRI, 4096,0,0,0); This task will setup the network (call NC_SystemOpen and NC_NetStart etc).

    I am always using NC_PRIORITY_HIGH in the NC_SystemOpen call. When I’m observing the problematic behavior, I have PRI set to 1. If set PRI = NC_PRIORITY_HIGH (which is 8) then everything works as expected. I don’t know why the original priority of the task should matter since the call to NC_SystemOpen changes the priority of the task (which I see in the ROV and debugger). But in my failure case, I see the priority of the task return to the original value of PRI that I had it set to (in my case it was 1).  

    regards -emil

  • emil,

    I expect that it should work with PRI == NC_PRIORITY_HIGH.  But, I don't think you should create the task with PRI == 1.

    Typically, the NDK network task is set to run at OS_TASKPRINORM (defaults to 5), so I would recommend creating it at that priority.  Furthermore, I would recommend that you *only* use the NDK's defined priority values (instead of hard numbers) when setting Task priorities (e.g. instead of "5" for a Task priority, use OS_TASKPRINORM).

    Just in case you have not already seen it, discussions on this in the NDK User's Guide (spru523h.pdf), it can be found in your NDK installation:

    3.1.2.3 Priorities for Tasks that Use NDK Functions

    4.2.2 Scheduling Options

    4.2.3 Scheduler Thread Priority

    Steve