OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Discussion to talk about software related topics only.
Post Reply
rob18767
Posts: 10
Joined: Fri Mar 06, 2020 6:38 am

OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Post 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
}
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Post 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.
rob18767
Posts: 10
Joined: Fri Mar 06, 2020 6:38 am

Re: OSTimeDly() from NBEclipse ver 2.7.1 to 2.7.7

Post by rob18767 »

A "background" task was running with to high a priority and that was the issue.
Post Reply