10-21-2009 03:34 AM
You are subtracting the Timestamps to get the difference of time, that may be even in milliseconds, right... ?!
IMO, it wont consume more process power because you are not spinning the loop infinitely; you already have a Wait statement to tell the loop when to time out regularly.
Even when you use Event Structure - ES, you can go down upto only milliseconds level of timeout, not microseconds. So, it should not make much difference, afaik...
10-21-2009 03:44 AM
You are right, but I meant something different:
I have several subvis to be performed at specific time points. The timing is not critical (+/- 20ms is ok), so I use a while loop and a stacked sequence to check if the time of each subvi has come. I run this while loop every 20ms (50 times a second).
If I needed the timing much more accurate (+/-1 ms) than I have to run the whileloop every ms, which is 1000 times per second.
I could imagine that this need a lot of cpu time. Do you understand what I mean?
10-21-2009 04:04 AM
Yes, I understood you very much already. Thats is why I told you can go down upto ms level, indirectly meaning down upto 1ms.
Try this... A simple while loop with a Wait function of 0.6ms will consume only 0% of your CPU even in a single core PC. But, if you go down to 0.5ms, it ll immediately shoot upto 100% CPU consumption. So, for a dual core or quad core, it ll be 50% or 25% respectively.
At a while loop spinning rate of 1ms timeout, the CPU consumption depends on the processes we do, like huge array manipulation, continuous file writing or continuous graph update on the FP which will require a total redraw (this can be reduced by deferring the FP updates till the finish) everytime its data gets changed.
10-21-2009 04:30 AM
parthabe wrote:
Try this... A simple while loop with a Wait function of 0.6ms will consume only 0% of your CPU even in a single core PC. But, if you go down to 0.5ms, it ll immediately shoot upto 100% CPU consumption. So, for a dual core or quad core, it ll be 50% or 25% respectively.
Because Wait Function required INTEGER input, isn't? 😉
Andrey.
10-21-2009 04:35 AM
johanneshoer wrote:
I see a problem. The timer value will wrap from (2^32)-1 to 0, so there might be a problem during comparison.
Even though it is very seldom, I can not accept that.
Not "very seldom" but exactly after 49,7 Days.
Unfortunately not all software engineers like you can catch such issue immediately:
Computer Hangs After 49.7 Days
Microsoft server crash nearly causes 800-plane pile-up
Andrey.
10-21-2009 04:44 AM
Andrey Dmitriev wrote:
Because Wait Function required INTEGER input, isn't? 😉
But still 0.6 is not INTEGER (I think it gets rounded off to the nearest, which is 1), right... ?!
And 0.5 gets rounded off to 0.
10-21-2009 04:48 AM
parthabe wrote:
But still 0.6 is not INTEGER (I think it gets rounded off to the nearest, which is 1), right... ?!
And 0.5 gets rounded off to 0.
Exactly!