CPU usage program

S

sethukr

Hi everybody,

Can anyone give me a simple program which would consumes more CPU
usage (more than 50%) in windows?

Thanks,
Sethu
 
S

santosh

Hi everybody,

Can anyone give me a simple program which would consumes more CPU
usage (more than 50%) in windows?

int main(void)
{
volatile unsigned long i = 0;
for (;;) i++;
return 0;
}
 
W

Walter Roberson

(e-mail address removed) wrote:
int main(void)
{
volatile unsigned long i = 0;
for (;;) i++;
return 0;
}

I'm wondering if the original poster has a dual-core or hyperthreaded
system, and thus needs a threaded or multi-process program in order
to "consume" more than 50% of the CPU usage on their system.
 
T

Tor Rustad

Hi everybody,

Can anyone give me a simple program which would consumes more CPU
usage (more than 50%) in windows?


The OS will try to stop such an application for consuming CPU cycles, so
either you need to write a *rootkit*, or fool the OS billing system.


Both methods, require *off-topic* code, which can be used by any
*clueless* script kid, to attack computer systems.


The <[email protected]> account, may already be tracked by US
authorities, so I suggest you go under ground... before getting into
trouble. :)
 
F

Flash Gordon

Walter Roberson wrote, On 08/10/07 16:26:
I'm wondering if the original poster has a dual-core or hyperthreaded
system, and thus needs a threaded or multi-process program in order
to "consume" more than 50% of the CPU usage on their system.

#include <stdlib.h>
int main(void)
{
for (;;) system("cpukiller");
}

Build the above and install the executable so that it can be invoked
successfully executed as cpukiller using the system function. That is
likely able to hit as many CPUs as you have.
 
R

Richard Tobin

Can anyone give me a simple program which would consumes more CPU
usage (more than 50%) in windows?

Either have fewer than two CPUs (increasingly tricky these days), or
write a multi-threaded program.

-- Richard
 
K

Keith Thompson

Tor Rustad said:
The OS will try to stop such an application for consuming CPU cycles,
so either you need to write a *rootkit*, or fool the OS billing system.
[...]

<OT>
Windows prevents any process from consuming more than 50% of the CPU?
Really? How do I enable this?
</OT>
 
R

Richard Heathfield

Keith Thompson said:

Windows prevents any process from consuming more than 50% of the CPU?

Yes. It achieves this by using 51% of the CPU itself.

<g,d&r>
 
E

Eric Sosman

Keith Thompson wrote On 10/08/07 16:33,:
Tor Rustad said:
The OS will try to stop such an application for consuming CPU cycles,
so either you need to write a *rootkit*, or fool the OS billing system.

[...]

<OT>
Windows prevents any process from consuming more than 50% of the CPU?
Really? How do I enable this?
</OT>

<OT>

Press the Windows "flag" key, press U, press U again.
(YMMV on non-English installations.)

</OT>
 
M

Martien Verbruggen

Either have fewer than two CPUs (increasingly tricky these days), or
write a multi-threaded program.

Or run more than one copy of the same program.

Martien
 
M

Mark McIntyre

Press the Windows "flag" key, press U, press U again.
(YMMV on non-English installations.)

Amusingly, Windows-U on my XP box invokes the Screen Magnifier and
attempts to read the menus to me...
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
T

Tor Rustad

Keith said:
Tor Rustad said:
The OS will try to stop such an application for consuming CPU cycles,
so either you need to write a *rootkit*, or fool the OS billing system.
[...]

<OT>
Windows prevents any process from consuming more than 50% of the CPU?
Really? How do I enable this?
</OT>

Keith, very off-topic! *shocked*

Try: remove the buggy kernel mode code, and see SetPriorityClass() and
SetThreadPriority() WIN32 API for ideas. :p

For Linux, BSD, Solaris, AIX, HPUX and Windows, user land programs can
consume more than >50% CPU. BUT, those OS'es try to avoid this, by
scheduling time interrupts, which bill the running process/thread. When
it's quota is up, the kernel scheduler typically put the running user
mode process/thread to sleep. I'm not sure what the actual limit is on
Windows, but it's there.

See e.g. "Modern Operating Systems" 2.ed, p.796, Tanenbaum.
 
R

Richard Tobin

Tor Rustad said:
For Linux, BSD, Solaris, AIX, HPUX and Windows, user land programs can
consume more than >50% CPU. BUT, those OS'es try to avoid this

General purpose operating systems try to allocate time fairly between
processes. If there are no other processes wanting the CPU, there is
no reason for the OS to stop a process from using 100%.

Most systems have a mechanism to give a process a higher or lower
priority if requested ("nice" in traditional unix).

-- Richard
 
T

Tor Rustad

Richard said:
General purpose operating systems try to allocate time fairly between
processes. If there are no other processes wanting the CPU, there is
no reason for the OS to stop a process from using 100%.


No process in user mode, will normally be able to gain 100%, except for
a *very* short time. Kernel will interrupt it, and do the scheduling and
it's internal work.

However, most likely OP was sitting with a dual core CPU... :)
 
P

Peter Pichler

Mark said:
Amusingly, Windows-U on my XP box invokes the Screen Magnifier and
attempts to read the menus to me...

Try doing it in sequence, as Eric Sosman suggested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top