开发者

Weird timing problem

开发者 https://www.devze.com 2023-01-24 19:30 出处:网络
EDIT Hey Guys thanks for your fast answers, I\'ve gotten a lot nearer to the problem, seems to be a present command that makes the devices answers faster (since I wait for every device answer this wou

EDIT Hey Guys thanks for your fast answers, I've gotten a lot nearer to the problem, seems to be a present command that makes the devices answers faster (since I wait for every device answer this would slow the whole thing down massivly) I`ll keep on trying or kill the device :P

Thanks

-

Sorry for the caption...I simply couldn't think of a better one. I am currently starting to think I'm mad or something like that.... :)

I'll first try to describe the problem with words...if nobody has an idea i'll try to extract the important parts...

Imagine the followi开发者_StackOverflowng: My app sends info via rs232 ports - so via an communicationsmonitor software I can watch exactly what data is sent and what time is between that.

Now I have 2 functions - to isolate the problem currently I have the exactly same while-loops containing the exact same code (I actually copied it!). Maybe the only difference is the code before the while loops are reached but even that isn't really anything big. So once the while loops are entered they run infinitly (just at the moment of course). As I said they contain the exact same sending routine.

But one is half as fast as the other one.... (WTF??????) :)

Now my first attempt was to place breakpoints 1 line above the "while"-line and one line beneath - The program never left the while loops...

So...can you guys maybe think of any other reasons this might have? Or possibilities to find out what it is....I'm kind of out of ideas after the breakpoint experiment showing that nothing but the same few lines are executed...

Oh btw no threads or something like that used here...so that can't be the reason either.

I'm looking forward to your ideas...thanks


Use a profiler to find where the extra cycles are going.


Given the exact same statement(s) that are run mltiple times there are absolutly no gurantees that they will have the same time of execution. There are a lot of external factors that can influence this, like CPU clock for instance.

You said that you don't have threads but your program is not the only one in the OS and you can't know what exactly the other processes do or how to control the time slice alocated to other processes.

You could set the Priority of your process higher but that still will not provide any guarantees and is not very recommended.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号