LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labwindows CVI application use 100% CPU?

While SleepUS is a very good solution, I also just wanted to point out that you can call Sleep on an RT system - you just need to include Windows.h in your source file.  Actually, a large number of Win32 SDK functions are available on Pharlap targets.

 

NickB

National Instruments

0 Kudos
Message 11 of 15
(1,326 Views)

Hello Umesh -

 

I'm sorry, I assumed you were talking about running CVI code on the Pharlap ETS RTOS.  I can see by reading your post more clearly that you are actually running a CVI Windows GUI application, and communicating with a Visual Studio application running on the RTX OS, via shared memory.

 

I'm not sure there's any way to perform deterministic operations with sub-millisecond resolution on the Windows OS.  Even if there were, I'm not sure it would be possible to do it without eating the entire processor time. 

 

NickB

National Instruments

0 Kudos
Message 12 of 15
(1,300 Views)

I am building a multithreaded application and try to use all the CPU power the 4 cores have. However I cannot force the computer to work on my tasks, a mere of 16% of total available CPU time is consumed,  even after setting the sleep policy to No sleep, and thread priorities to 15. In addition I am runing 16  threads in parralel in a new threadpool. I even removed all io and user interface calls;  

Tthe CPU has 4 cores with 8 hypertheding channels.

What should I do to increase the CPU time usage by my applications and not let windows fall in idling .

Windows leaves 2 hyperthreading cores unassigned, the rest seem to use at around 30% of the CPU time.

This is not good. I need all the power the CPU can give me.

0 Kudos
Message 13 of 15
(1,206 Views)

Hi Layosh,

 

First, if you need more reliable thread usage and determinism in your application, then I would suggest switching to a real-time OS. While sometimes you can manipulate Windows to handle thread load balancing the way you want it to, it is really not designed for applications to take up 100% CPU usage. Windows will limit the CPU time of an application to prevent it from hogging all of the resources. So even if you don't have I/O, it will still thread switch on you. This is why I would recommend a real-time OS where it will not do this.

 

However, 16% CPU usage is pretty low. It sounds like your threads are mostly running on the same processor. If you look in the Performance tab in the Task Manager, it will show you the CPU usage of each core. Do you see a spike in only 1 or 2 of the cores? One thing you can try is to spread the processor load balance by assigning a processor affinity to each core. Attached is a sample application that takes a set of threads and assigns a different processor to each thread. Running this on my system gives me 100% usage if I have more threads than cores.

 

 

National Instruments
0 Kudos
Message 14 of 15
(1,170 Views)

Thanks,

The example you sent me runs on 5 threads at 100%, and the remaining 3 runst at 10% or so  according to the TaskManager-Performance ,monitor.

After increasing the thread number to 16  (as in my program) yours forces windows to be busy 100% in all 8 threads. Mine is still 13-18%.  I try to find what causes the difference... I am running mine in a new threadpool, with 16 threads; Could that make the difference? 

The RealTime OS should not be necessary, since I am not interested in rapid or exact timing, just need all the processign power of those 4 kernels of the peski CPU. I am mowing that part to GPU, but need that raw speed to feed the 1024 and some processors on my set of Graphics cards that are capable of something neer teraflops; and keep them busy by repeatedly preprocessing over 9 million arrays on the host. into a format that can easylly handled by the GPU.

 

0 Kudos
Message 15 of 15
(1,164 Views)