cual core, quad core, i3,i5,i7 optimized and 100% cpu's
Hello,
I would like a sample source code for create a program where use 100% of all CPU's/cores on dual/quad core or new I3,I5,I7.
For example: i have a simple program for calculating a numbers, but, when i start only have usage 50% of my dual core, the other is 0% usage. I would like use the two cores at time.
thanks all.
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
can use a infinite for loop...
Code:
for (;;)
{
for (;;)
{
//some stuffs.. like:: FindWindow(). Finding a window that is not created yet. so the loop continues.
//a break statements if you want to terminate infinite loop.
}
}
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
Quote:
Originally Posted by
hypheni
can use a infinite for loop...
No, that won't work. When executed on a dual-core machine, the "infinite loop" code would still show only 50% utilization.
To the OP, you need to understand threading. To use multiple cores simultaneously, your code needs to start multiple threads.
The "infinite loop" code above is still only singly-threaded, and thus will not use all cores.
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
Quote:
To use multiple cores simultaneously, your code needs to start multiple threads.
Multiple child threads belonging to a single task doesn't always mean multiple cores are used... this all depends on the OS and the optimization used by the OS and which instructions are used. So, which OS is used for this question ?
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
SO: LINUX or Windows 7 64
I need only a example code for use 2 or 4 core together=100% cpu!!!
thanks all,
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
See. Some days back I used a for(;;) with some statements inside on my dual core win xp machine and it was almost utilizing 90-100% of cpus. Multiple threading will be a good choice but I think putting preferred statements in nested for(;;) also utilize 100% of cpu. It depends on what you are putting inside the loop.