LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI does not change sleep policy back to MORE after setting NONE.

One part of my application requires a Sleep Policy setting of NONE, whereas another portion requires a setting of MORE. This is determined by what specific hardware the application is communicating with during different times.
The problem is that once setting sleep policy to NONE, no other setting alters the effective functioning of the application. Setting sleep policy to NONE causes the application to use 99% CPU utilization (which is just fine). Setting sleep policy to MORE causes the application to use 2% CPU utilization. I can detect this by observing the task CPU utilization in the Windows Task Manager. Extensive experimentation has revealed that once the sleep policy has been set to NONE even once, an
y further setting of the sleep policy has no effect on the CPU utilization of the application. This causes the portion of the application that requires the MORE setting to stop functioning. This is true REGARDLESS of what the GetSleepPolicy() function returns as what it thinks is the 'current' setting of the sleep policy.
0 Kudos
Message 1 of 4
(3,313 Views)
I could not reproduce the problem you are seeing. What I did was just create a UI with two buttons, one that set the sleep policy to Sleep More, and one that set it to Do Not Sleep. When I pressed the Sleep More button, CPU usage dropped to close to 0%. When I pressed Do Not Sleep, it ran up to about 99%. I could go back and forth fine and see the CPU usage go up and back down.

It's possible that you have a multithreaded application or are using asynchronous timers that are running very quickly that is causing this issue. Also, I'm not sure what version you are using (I'm in CVI 7.0). It could be an issue in an older version.

I would recommend trying the simple example I described above. If that works, then look for asynch timers, other thre
ads, or some other message looping that could be monopolizing the CPU. If you are using CVI 7.0, my example code is attached.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 4
(3,313 Views)
Chris,

I am humbled to say this was an unfortunate miscommunication with my associates here. Your example does, of course, work with CVI 5.0 as well it should.

Please accept my apologies on behalf of the cretins who caused this misunderstanding for even bringing up this issue. The offending individuals have been appropriately chastised and ask your forgiveness. And thank you so much for your rapid reply to the 'issue'.

Respectfully,
Lew Nathan
0 Kudos
Message 3 of 4
(3,313 Views)
Very amusing. Don't be too hard on them, all us programmers make those mistakes sometimes. By the way, CVI 7.x is an amazing upgrade from where you are in CVI 5.0. You may have a good reason for staying with 5.0, but I would recommend evaluating CVI 7.0. You can get an evaluation copy sent to you free by filling out the form at http://sine.ni.com/apps/we/nigb.guestbook?code=GB_EVALCVI〈=US&gb_prof_id=1323&scode=&pr=1323.

Happy programming,

Chris
0 Kudos
Message 4 of 4
(3,313 Views)