Hi..
I have written a C++ program to compress and decompress jp2k files. But when I am executing this program the CPU usage is 100%... Can any one tell me :
why is it so and
how to reduce CPU usage?

I have compiled same code on windows and Linux platform But CPU usage is 100 % on linux and 50 % on Windows.

Recommended Answers

All 4 Replies

It's not a C++ issue, it's your operating system that doles out CPU time to the program. It sounds like yours is a pretty compute-intensive app, so it will take a lot of CPU time. Is your Linux/Windows disparity on the same machine (dual boot) or are you testing on two different boxes? Does the Windows box have a dual core processor?

Post the code here, we will have a look to see whether there is some optimization issue with your code.

It's not a C++ issue, it's your operating system that doles out CPU time to the program. It sounds like yours is a pretty compute-intensive app, so it will take a lot of CPU time. Is your Linux/Windows disparity on the same machine (dual boot) or are you testing on two different boxes? Does the Windows box have a dual core processor?

hi..
I am executing it on two different boxes. No Windows machine does not have dual core processor.
Thanx for your quick reply.. So can I reduce this CPU utlization by some way?

Well on Linux, you could use the nice() function to lower the priority of your process, so that it spends more time doing other things.

Windows has a similar feature, a search for 'Priority' through MSDN might prove useful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.