CPU usage program

Discussion in 'C Programming' started by sethukr@gmail.com, Oct 8, 2007.

  1. Guest

    Hi everybody,

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

    Thanks,
    Sethu
    , Oct 8, 2007
    #1
    1. Advertising

  2. santosh Guest

    wrote:

    > 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;
    }
    santosh, Oct 8, 2007
    #2
    1. Advertising

  3. In article <fedhm3$66h$>, santosh <> wrote:
    > wrote:


    >> 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;
    >}


    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.

    --
    We regret to announce that sub-millibarn resolution bio-hyperdimensional
    plasmatic space polyimaging has been delayed until the release
    of Windows Vista SP2.
    Walter Roberson, Oct 8, 2007
    #3
  4. Tor Rustad Guest

    wrote:
    > 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 <> account, may already be tracked by US
    authorities, so I suggest you go under ground... before getting into
    trouble. :)


    --
    Tor <torust [at] online [dot] no>
    Tor Rustad, Oct 8, 2007
    #4
  5. Flash Gordon Guest

    Walter Roberson wrote, On 08/10/07 16:26:
    > In article <fedhm3$66h$>, santosh <> wrote:
    >> wrote:

    >
    >>> 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;
    >> }

    >
    > 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.
    --
    Flash Gordon
    Flash Gordon, Oct 8, 2007
    #5
  6. In article <>,
    <> wrote:

    >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
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, Oct 8, 2007
    #6
  7. Tor Rustad <> writes:
    > wrote:
    >> 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.

    [...]

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

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Oct 8, 2007
    #7
  8. Keith Thompson said:

    <snip>

    > 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>

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Oct 8, 2007
    #8
  9. Eric Sosman Guest

    Keith Thompson wrote On 10/08/07 16:33,:
    > Tor Rustad <> writes:
    >
    >> wrote:
    >>
    >>>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.

    >
    > [...]
    >
    > <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>

    --
    Eric Sosman, Oct 8, 2007
    #9
  10. On 8 Oct 2007 20:24:04 GMT,
    Richard Tobin <> wrote:
    > In article <>,
    > <> wrote:
    >
    >>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.


    Or run more than one copy of the same program.

    Martien
    --
    |
    Martien Verbruggen | Freudian slip: when you say one thing but
    | mean your mother.
    |
    Martien Verbruggen, Oct 8, 2007
    #10
  11. On Mon, 08 Oct 2007 17:21:52 -0400, in comp.lang.c , Eric Sosman
    <> wrote:

    > 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
    Mark McIntyre, Oct 8, 2007
    #11
  12. Tor Rustad Guest

    Keith Thompson wrote:
    > Tor Rustad <> writes:
    >> wrote:
    >>> 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.

    > [...]
    >
    > <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.

    --
    Tor <torust [at] online [dot] no>
    Tor Rustad, Oct 8, 2007
    #12
  13. In article <>,
    Tor Rustad <> wrote:

    >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
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, Oct 8, 2007
    #13
  14. Tor Rustad Guest

    Richard Tobin wrote:
    > In article <>,
    > Tor Rustad <> wrote:
    >
    >> 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%.



    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... :)

    --
    Tor <torust [at] online [dot] no>
    Tor Rustad, Oct 9, 2007
    #14
  15. Re: CPU usage program [OT]

    Mark McIntyre wrote:

    > On Mon, 08 Oct 2007 17:21:52 -0400, in comp.lang.c , Eric Sosman
    > <> wrote:
    >
    >> 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...


    Try doing it in sequence, as Eric Sosman suggested.
    Peter Pichler, Oct 15, 2007
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davy

    Control CPU usage of a program?

    Davy, Aug 21, 2005, in forum: C Programming
    Replies:
    6
    Views:
    1,332
    HalleHamar
    Nov 4, 2012
  2. Robert
    Replies:
    3
    Views:
    403
    Chris Hills
    Aug 21, 2005
  3. hvt
    Replies:
    0
    Views:
    1,209
  4. hvt
    Replies:
    0
    Views:
    1,469
  5. Sethu

    CPU usage program

    Sethu, Oct 8, 2007, in forum: C++
    Replies:
    11
    Views:
    635
    Zeppe
    Oct 9, 2007
Loading...

Share This Page