tags:

views:

249

answers:

3

Noted that the parameter of taskDelay is of type int, which means the number could be negative. Just wondering how the function is going to react when passing a negative number.

A: 

Most functions would validate the input, and just return early/return 0/set the parameter in question to a default value.

Hooked
A: 

I presume there's no critical need to do this in production, and you probably have some code lying around that you could test with.... why not give it a go?

Dave Gamble
+1  A: 

The documentation doesn't address it, and the only error codes they do define don't cover this case. The most correct answer therefore is that the results are undefined.

See the VxWorks / Tornado II FAQ for this gem, however:

taskDelay(-1) shows another bug in the vxWorks timer/tick code. It has the (side) effect of setting vxTicks to zero. This corrupts the localtime (and probably other things). In fact taskDelay(x) will have the same effect if vxTicks + x >= 0x100000000. If the system clock rate is 100Hz this happens after about 500 days (because vxTicks wraps). At faster clock rates it will happen sooner. Anyone trying for several years uptime?

Oh there is an undocumented upper limit on the clock rate. At rates above 4294 select() will fail to convert its 'usec' time into the correct number of ticks. (From: David Laight, [email protected])

Assuming this bug is old, I would hope that it would either return an error or do the same thing as taskDelay(0), which puts your task at the end of the ready queue.

Chris Arguin