Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

how to find cpu is idle or not???

Thread view: 
master007 - 16 Feb 2006 17:38 GMT
hi...

how to find cpu is idle or not using java programming...
bye..
frnds...
waiting for ur reply..
Eric Sosman - 16 Feb 2006 17:47 GMT
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?

Signature

Eric.Sosman@sun.com

Bent C Dalager - 16 Feb 2006 18:23 GMT
>    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
Signature

Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
                                   powered by emacs

Oliver Wong - 16 Feb 2006 18:53 GMT
> master007 wrote On 02/16/06 12:38,:
>> hi...
[quoted text clipped - 12 lines]
>
>    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
Eric Sosman - 16 Feb 2006 19:26 GMT
Oliver Wong wrote On 02/16/06 13:53,:

>>master007 wrote On 02/16/06 12:38,:
>>
[quoted text clipped - 16 lines]
>     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 ...

Signature

Eric.Sosman@sun.com

master007 - 05 Mar 2006 08:17 GMT
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...
Roedy Green - 05 Mar 2006 15:21 GMT
>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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Alun Harford - 05 Mar 2006 16:21 GMT
> 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
Dimitri Maziuk - 05 Mar 2006 19:58 GMT
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
Signature

Surely there is a polite way to say FOAD.                        -- Shmuel Metz
"Go forth and multiply".                                         -- Paul Martin

Oliver Wong - 06 Mar 2006 19:25 GMT
> Sir...
> iam doing file searcher in hard disk.
[quoted text clipped - 8 lines]
>
> ThankU Sir...

I made a post about this earlier. See

http://tinyurl.com/jvvad

(original URL is:

http://groups.google.ca/group/comp.lang.java.programmer/browse_frm/thread/3edac1
e4ce9a2ece/ceaa37335d33440e#ceaa37335d33440e


)

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.