how to find cpu is idle or not???

Discussion in 'Java' started by master007, Feb 16, 2006.

  1. master007

    master007 Guest

    hi...

    how to find cpu is idle or not using java programming...
    bye..
    frnds...
    waiting for ur reply..
     
    master007, Feb 16, 2006
    #1
    1. Advertising

  2. master007

    Eric Sosman Guest

    master007 wrote On 02/16/06 12:38,:
    > hi...
    >
    > how to find cpu is idle or not using java programming...
    > bye..
    > frnds...
    > waiting for ur reply..


    static boolean CPUIsIdle() {
    return false;
    }

    .... because the CPU cannot be idle if it's executing
    the method.

    What's your *real* question?

    --
     
    Eric Sosman, Feb 16, 2006
    #2
    1. Advertising

  3. In article <dt2dqp$67r$>,
    Eric Sosman <> wrote:
    >
    >
    > static boolean CPUIsIdle() {


    I would recommend "isCpuIdle()" in stead :)

    > return false;
    > }
    >
    >... because the CPU cannot be idle if it's executing
    >the method.


    There could presumably be a callback the CPU could invoke when it
    knows that it otherwise would have been idle though.

    Cheers
    Bent D
    --
    Bent Dalager - - http://www.pvv.org/~bcd
    powered by emacs
     
    Bent C Dalager, Feb 16, 2006
    #3
  4. master007

    Oliver Wong Guest

    "Eric Sosman" <> wrote in message
    news:dt2dqp$67r$...
    >
    >
    > master007 wrote On 02/16/06 12:38,:
    >> hi...
    >>
    >> how to find cpu is idle or not using java programming...
    >> bye..
    >> frnds...
    >> waiting for ur reply..

    >
    > static boolean CPUIsIdle() {
    > return false;
    > }
    >
    > ... because the CPU cannot be idle if it's executing
    > the method.
    >
    > What's your *real* question?


    What if the user has a multi-cpu machine, and the Java code is running
    on one CPU, but querying a different CPU? ;)

    - Oliver
     
    Oliver Wong, Feb 16, 2006
    #4
  5. master007

    Eric Sosman Guest

    Oliver Wong wrote On 02/16/06 13:53,:
    > "Eric Sosman" <> wrote in message
    > news:dt2dqp$67r$...
    >
    >>
    >>master007 wrote On 02/16/06 12:38,:
    >>
    >>>hi...
    >>>
    >>>how to find cpu is idle or not using java programming...
    >>>bye..
    >>>frnds...
    >>>waiting for ur reply..

    >>
    >>static boolean CPUIsIdle() {
    >> return false;
    >>}
    >>
    >>... because the CPU cannot be idle if it's executing
    >>the method.
    >>
    >> What's your *real* question?

    >
    >
    > What if the user has a multi-cpu machine, and the Java code is running
    > on one CPU, but querying a different CPU? ;)


    That's the sort of clarification I hope he'll offer,
    along with what he means by "CPU" and by "idle." I also
    admit to some puzzlement about why he thinks an answer
    would be useful ...

    --
     
    Eric Sosman, Feb 16, 2006
    #5
  6. master007

    master007 Guest

    Sir...
    iam doing file searcher in hard disk.
    i have to scan the hard disk...
    if i scan the comp when it is loaded...system performance will be
    degraded..
    so i want to know wheather cpu is idle or not..?
    if it is idle..i can use that time ...with causing inconvience to
    user...

    I think u Got my Point Sir...

    ThankU Sir...
     
    master007, Mar 5, 2006
    #6
  7. master007

    Roedy Green Guest

    On 5 Mar 2006 00:17:52 -0800, "master007" <>
    wrote, quoted or indirectly quoted someone who said :

    >so i want to know wheather cpu is idle or not..?


    you could detect that by creating a very low priority thread that did
    something inane like compute pi. You check in on it after a second
    to see how much it has accomplished. If a lot, then the machine is
    idle.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 5, 2006
    #7
  8. master007

    Alun Harford Guest

    "master007" <> wrote in message
    news:...
    > Sir...
    > iam doing file searcher in hard disk.
    > i have to scan the hard disk...
    > if i scan the comp when it is loaded...system performance will be
    > degraded..
    > so i want to know wheather cpu is idle or not..?


    No you don't - you just want to schedule the thread with minimum priority.
    If the JVM is any good, Java threads are mapped to OS threads, and it'll get
    run with minimum priority by the OS.

    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

    Alun Harford
     
    Alun Harford, Mar 5, 2006
    #8
  9. master007 sez:
    > Sir...
    > iam doing file searcher in hard disk.
    > i have to scan the hard disk...
    > if i scan the comp when it is loaded...system performance will be
    > degraded..
    > so i want to know wheather cpu is idle or not..?


    You can't: it's like opening the box except the cat is dead
    100% of the time.

    The code for checking must be executed by the cpu, so when
    the check runs cpu will always be busy -- running the check.

    HTH,HAND
    Dima
    --
    Surely there is a polite way to say FOAD. -- Shmuel Metz
    "Go forth and multiply". -- Paul Martin
     
    Dimitri Maziuk, Mar 5, 2006
    #9
  10. master007

    Oliver Wong Guest

    "master007" <> wrote in message
    news:...
    > Sir...
    > iam doing file searcher in hard disk.
    > i have to scan the hard disk...
    > if i scan the comp when it is loaded...system performance will be
    > degraded..
    > so i want to know wheather cpu is idle or not..?
    > if it is idle..i can use that time ...with causing inconvience to
    > user...
    >
    > I think u Got my Point Sir...
    >
    > ThankU Sir...
    >


    I made a post about this earlier. See

    http://tinyurl.com/jvvad

    (original URL is:

    http://groups.google.ca/group/comp....1e4ce9a2ece/ceaa37335d33440e#ceaa37335d33440e

    )

    - Oliver
     
    Oliver Wong, Mar 6, 2006
    #10
    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. Irmen de Jong
    Replies:
    0
    Views:
    464
    Irmen de Jong
    Jun 9, 2004
  2. calculation of cpu idle time

    , Aug 23, 2006, in forum: C Programming
    Replies:
    33
    Views:
    1,022
    jmcgill
    Aug 29, 2006
  3. calculation of cpu idle time

    , Aug 23, 2006, in forum: C Programming
    Replies:
    2
    Views:
    722
    Flash Gordon
    Aug 23, 2006
  4. pavunkumar

    How , system cpu and user cpu times calculates

    pavunkumar, Feb 27, 2009, in forum: C Programming
    Replies:
    1
    Views:
    364
  5. inetquestion

    cpu idle measurement: sar/vmstat

    inetquestion, Oct 23, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    139
    Charles DeRykus
    Oct 26, 2006
Loading...

Share This Page