[ prev | next | up ]

Calculating internal priority

> Is there any formula to recalculate the priority of a thread, or do we
> just have to think up one ourselves?  For example, if I am modifying
> priority based on the amount of time the thread has used the CPU, how many
> time units correspond to one priority unit?  Should I make a thread have
> higher priority if it has been blocked?  
There are many formulae that could be used. The specifics (such as whether to treat blocked threads differently from ready threads or how much time corresponds to one unit of priority) are up to you. But in general, the function should be of the form:
        internal_priority = f(time_used_cpu, time_waited_for_cpu, external_priority)
where f() is Recall that higher priorities correspond to lower values.