Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi i am currently writing a programme using multithreading. Multithreading is used to utilize CPU fully.
my current programme is running well but CPU utilization is around 40-50% for the entire running.

As per the multithreading theory it should be 100% for at lest some time.

Since even after doing multi threading the CPU utilization is 50% only, can it be treated as failed multithreading ??

I am using a single core processor without hyperthreading. The application do not allow human intervention. it has a function which calculates a lot. one gui thread + one worker thread.


Q.

Is it a rule that for a application in which multithreading is successfully implemented CPU utilization MUST be 100%.
anything less be treated as failed multithreading ??

For successful multithreading what should be the ideal CPU utilizaion on

1.single core and
2.multicore processors.

All cores should be used to 100% or what is the exact criteria to know if the multithreadig is successful.

Or asking in different way

1. while running my program if CPU utilization is below 100% is there any scope of improvement in terms of design of program and / or coding ??

100% need not be literal but very high say 90% or above as currently the utilization is about 50%.


Experts please comment.
Posted
Updated 11-Mar-11 19:03pm
v4

Both criteria are nonsense. There are many reasons to use threading, but only for some tasks 100% of CPU usage is desired. Example of such task is long-lasting calculations without human intervention. There are many such tasks, such as numerical simulation of complex models. But! In all these cases the problem of 100% CPU utilization is not really a problem. If you run one such task, a single-CPU computer will be 100% busy anyway. The case of the system with multiple cores/CPUs the problem is more complex, but no reduced to the problem of 100% CPU usage. You can easily keep 100% CPU busy still having the effective throughput of your task unsatisfactory (even when no thread is doing anything stupid from its local standpoint, such as spin-wait). The real goal it to complete the given volume of calculation sooner, which is a very different problem, much more complex.

In this way, the problem of 100% CPU utilization is mostly artificial and is not much relevant to the really difficult problem of effectiveness of parallel calculation.

—SA
 
Share this answer
 
v2
Comments
Albin Abel 12-Mar-11 3:47am    
it is agreeable that 100% CPU is not a criteria for multi threading. 100% CPU is related to processor intensive operations. Multi threading can be assumed in such a way that a heavy load a person trying to move through hole, then it takes long time. But if the heavy load is split and given for many persons then every one can move faster than the single person, provided the size of the hole. Size of the hole can be comparable to CPU availability and numbers. That doesn't need to fill the CPU any way unless it do processor intensive operations. My 5++
Sergey Alexandrovich Kryukov 12-Mar-11 14:56pm    
Thank you, Albin,
I agree; this is good point.
--SA
thatraja 12-Mar-11 8:47am    
Fine answer SA. BTW bookmarked this.
Sergey Alexandrovich Kryukov 12-Mar-11 17:37pm    
Thank you.
--SA
Nuri Ismail 12-Mar-11 11:35am    
Excellent answer! 5+
You must be running a processor with mutliple processors (virtual). As a result, you will see a maximum utilization of only 50% on that processor.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-11 0:49am    
Sorry, Abhinav, did you actually try to use 100% in multiple cores? I did. Easily! The problem is not so simple as 100% CPU, please see my Answer.
(I did not vote this time.)
--SA
Abhinav S 12-Mar-11 8:08am    
Ok makes some sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900