Re: How to run tasks with priority?



Thanks Boudewijn,


Boudewijn Dijkstra wrote:
>> Thanks Boudewijn,
>>
>[quoted text clipped - 23 lines]
>> program. So I have tried and used performance monitor of task manager of
>> Windows XP (invoked from "My Computer") to monitor CPU usage. Am I correct?
>
>That is fine for this example. ;)
>
>> I have found that when yield is running, the CPU usage is very high, and
>> when sleep is running, te CPU usage is very slow. Do you know why when
>> running yield, CPU usage is high? What is CPU busy doing at that time (in
>> my mind, I think CPU has nothing to do when running yield, just as when
>> running sleep)?
>
>The API documentation description of yield() is a bit cumbersome. But it is
>enough for those who are educated in the most important concepts of task
>scheduling. Sensing that you are not, I will explain what happens when
>yield() is called.
>
>1. The current thread is paused, but remains ready to run.
>2. The task scheduler checks the current priority queue for threads (other
>than the current one) that are ready to run.
>3a. If there are, then perform a task-switch to the first one.
>3b. If there aren't, then un-pause the current thread.
>
>Note that, although the current thread is suspended, the CPU always has
>something to run during steps 1,2,3.

Your description is very helpful and it has answered my question. Do you
know whether there exists a tool which can monitor what threads are running
on a VM and how much running time they have allocated from VM, just like
the performance monitor of task manager of Windows XP (invoked from "My
Computer")? If there exists such a tool in Java, it will make our work very
convenient, isn't it? :-)

>> Another small issue is that, why you use join method in your getFinalScore
>> method? I have not seen its special functons yet.
>
>When 'running' is set to false, the thread does not immediately exit. By
>calling join(), the thread that executes getFinalScore() waits for it to exit
>so that it can fetch the *final* score.
>

Your idea of using join is very intelligent!


regards,
George

--
Message posted via http://www.javakb.com
.



Relevant Pages

  • Re: CPU performance peaks and stalls
    ... Open Task Manager and watch the processes (sort them by the CPU column ... will run when there is an Internet connection. ... Not all programs that reduce their CPU usage when Task Manager is opened ...
    (microsoft.public.windowsxp.newusers)
  • Strange CPU usage
    ... I recently had a hard drive failure, just broke, so re-installed ... programs would freeze, Task Manager showed 2 copies of the program, ... show any process with an excessive CPU usage, ... jumps about between 20% and 60%, with jumps to 100%, but at the same ...
    (microsoft.public.windowsxp.general)
  • Re: Services running high and CPU usage high
    ... I looked in Task Manager and I can see that services are running very high ... and CPU usage is high also even when I do not perform any tasks. ... My computer parameters: ... I have this problem for the last few weeks and it is driving me crazy. ...
    (microsoft.public.win2000.general)
  • Re: CPU process
    ... >> On boot there is NO other app`s runing only task manager (there are ... >> Process is at 95-99% BUT IN THE SAME TIME it is showing that CPU usage ... > Please learn how to post - this is Usenet, ... > How to Compose a Good Newsgroup Post ...
    (microsoft.public.windowsxp.general)
  • Re: poor performance and disk thrashing
    ... How much RAM memory? ... click the Performance Tab. ... What process is generating high CPU usage? ... Task Manager is useful but you could look at another freeware utility ...
    (microsoft.public.windowsxp.help_and_support)