Find out the system frequency in wince 7 - c++

I have a system that runs on wince 7.
I have encountered a problem in which the system slows down after a while.
How can I find out the system frequency?

There are several methods (depending on the information you want):
You can use the toolhelp api to find how much processor time each application is using. http://www.codeproject.com/Articles/159461/Mobile-Processor-Usage
IOCTL_PROCESSOR_INFORMATION will tell you what kind of processor is in your system and what clock speed it is running at. http://www.codeproject.com/Tips/122843/What-processor-is-in-my-mobile-device
GetIdleTime() can be used to tell you how busy your processor is overall: http://www.codeproject.com/Tips/133104/Mobile-processor-usage

Related

GUI loading issue on Windows compare to OsX

I use Juce C++ 4.0.2 to build an audio plugin with a relatively heavy GUI. It takes 5s to load the GUI on a DAW like reaper on OsX, but it takes 10 times more on Windows using the same DAW.
I eventually figure out that is it due to the Typeface::createSystemTypefaceFor function that takes 100ms on Windows. It was an issue on my side because I used it many times.
Does anyone face the same issue?
Typeface::createSystemTypefaceFor is not designed to be called frequently; you should call it once for each typeface ideally and cache the results. Calling it frequently will cause a performance hit which varies depending on platform, as you are experiencing.

Increase performance of Windows apps

I have imported an app from Visual Studio compiler to MinGW and I faced a problem – performance degradation. Usage of CPU increased from 30% to 100%.
There is one interesting thing. If before running my app or during, I’ve run Windows Media Player – performance of my app is going to fine. CPU usage is going down till 30% and works faster (about 10 times faster).
I’ve googled it and found. It relates to a service, which names as a Multimedia Class Scheduler Service (MMCSS). The main problem is: this service forks under Windows Vista and later, but I’ve tested and imported my app under Win XP.
So, does anyone know how to use this feature under XP? And how Windows Media Player increases performance of my app?
Windows Media Player changes the resolution of the system multimedia timer. Basically, this occurs when your application really should be using something like the High Performance Timer but is using the multimedia timer instead, which simply doesn't have and isn't intended to have the necessary accuracy or resolution to be a high-performance timer. As a result, any timings in your program essentially don't work as they should, which is especially bad if you're trying to sleep or block for a fixed time.

What is the interface that change the cpu frequency and the core voltage on the windows platform?

I want to find the interface supplied by windows to change the CPU frequency and core voltage.
Thanks!
you can change frequency by using
PowerWriteACValueIndex()/PowerWriteDCValueIndex()
when setting the same index value for both
GUID_PROCESSOR_THROTTLE_MAXIMUM | GUID_PROCESSOR_THROTTLE_MINIMUM
all the GUID description could be found in winnt.h
you cannot change CPU voltage by WINAPI. you should use the privileged commands to write to specific MSRs (see AMD/Intel docs) via system kernel driver.
you cannot change Intel CPU voltage AT ALL since Nehalem micro-architecture. Intel officially does not supply MSRs to write voltage values (VIDs) by software.
From Windows Native Processor Performance Control(document link)
Parameters to P-state policy
Several parameters to Windows processor performance state controls are configurable via registry keys. These keys are provided with the intent that OEMs and system designers may tune the performance of Windows processor power management features to best suit specific platform designs, and allow adjustment to help achieve maximum battery life and realize the best system performance.
And you have to restart to have the changes take effect.
Microsoft Windows does not have an API for overclocking / underclocking a CPU. You would have to roll your own using your assembler skills.
I can do no more than point you in the right direction. I think through Windows Management Instrumentation (WMI) you can get at a COM interface that allows modification of some sub-systems.
Hopefully that vague bit of information will set you on the right path. :-)

Determining CPU usage in WinCE

I want to be able to get the current % CPU usage in a C++ program running under Wince.
I found this link that states where the source code is but I cannot find it in my platform builder installation - I expect this is because it isn't the Windows Automotive platform.
Does anyone know where I can find this source code or (even better) know how I can get this information directly? i.e. what DLL / function calls to make etc.
Since GetProcessTimes doesn't exist in CE, you have to calculate this.
You have to start with the toolhelp APIs to enumerate the processes and the threads in the processes. You then call GetThreadTimes for each thread and add all that up.
Bear in mind that the act of calculating this info will affect the CPU utilization.
I have found that GetIdleTime (or CeGetIdleTimeEx on WEC7 or newer) works well for calculating system-wide processor usage. Sample code for calculating processor idle time percentage is shown on GetIdleTime MSDN page. Obviously, processor utilization percentage can then be calculated by subtracting the idle time percentage from 100.
The MSDN page does warn that support for GetIdleTime is dependent on OAL implementation.
Note that when using the toolhelp APIs to calculate the CPU usage, you need to take two measurements, then calculate the difference. when doing so, you won't know how much CPU any threads that were terminated before the second sample took.
So, applications that often create short-lived threads will not be represented properly in your result.
You can look into Remote Task Monitor. It will let you get the current % CPU usage of your process (or thread), exactly what you are looking for. It also is very light weight, does not impact your device much.

monitor cpu usage per thread on windows mobile device

Is is possible to measure CPU per thread on a windows mobile (or CE 5) device programmatically (c++)? If not, is their a utility that will monitor the CPU usage of a process?
CPU usage cannot be directly measured because, unlike an x86, the ARM processor doesn't have a register for it. You can calculate it using the Toolhelp APIs to get a list of processes and their child threads and then use GetThreadTimes to figure out how much time each thread is using.
Keep in mind that doing this calculation directly affects how much the CPU is in use.
Someone wrote a tool that looks a lot like Task Manager on the PC:
http://www.vttoth.com/LPK/taskmanager.html
As ctacke says, it does seem to use a lot of the CPU. It reports uses ~15%-30% of our CPU on our 800MHz ARM device.