-
July 26th, 2010, 04:21 AM
#1
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.
-
July 26th, 2010, 05:33 AM
#2
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.
}
}
Last edited by hypheni; July 26th, 2010 at 05:36 AM.
-
July 26th, 2010, 01:40 PM
#3
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
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.
-
July 26th, 2010, 02:19 PM
#4
Re: cual core, quad core, i3,i5,i7 optimized and 100% cpu's
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 ?
-
July 26th, 2010, 03:47 PM
#5
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,
-
July 27th, 2010, 12:40 AM
#6
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.
Last edited by hypheni; July 27th, 2010 at 12:43 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|