Page 1 of 1

OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Posted: Fri Mar 20, 2020 1:12 pm
by rob18767
I have managed to compile code that was last compiled in NBEclipse 2.7.1 in version 2.7.7.

In an OS task I have the line

OSTimeDly(60);

I this causes the thread to hang (the code cannot get past this point).

Any idea why?

There is also a forever loop in main

while (true)
{
//OSDumpTCBStacks(); // dump stack usage

OSTimeDly(1200); // 50ms * 20 * 60 = 1 Minute
}

Re: OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Posted: Fri Mar 20, 2020 2:23 pm
by TomNB
Hello,

For any delay, I would use the TICKS_PER_SECOND value to make things easier to read. There are 20 ticks per second. So in your first delay: OSTimeDly(TICKS_PER_SECOND * 3);

The time delay isn't causing your task to hang, but I do have a guess. In a real time preemptive operating system, "the highest priority task ready to run will run". Functions that block and interrupts will invoke the scheduler, which will evaluate the tasks and switch to a higher one if it is ready. OSTimeDly() is a blocking function. My guess is that the way you set up the priorities there is a higher priority task running all the time which does not ever block and let lower priority tasks run.

The NNDK Programming Guide has a lot more information on this.

Re: OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Posted: Wed Mar 25, 2020 11:28 am
by rob18767
A "background" task was running with to high a priority and that was the issue.