forked from len0rd/rockbox
Threads of PRIORITY_REALTIME and above are no longer subject to being switched away based upon aging of lower priority threads. Now, recommend a thread switch in wakeup_thread of any thread of higher priority is ready to run.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25666 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1a10c75c03
commit
d6cd1bc58e
1 changed files with 18 additions and 10 deletions
|
|
@ -2062,16 +2062,23 @@ void switch_thread(void)
|
|||
|
||||
/* This ridiculously simple method of aging seems to work
|
||||
* suspiciously well. It does tend to reward CPU hogs (under
|
||||
* yielding) but that's generally not desirable at all. On the
|
||||
* plus side, it, relatively to other threads, penalizes excess
|
||||
* yielding which is good if some high priority thread is
|
||||
* performing no useful work such as polling for a device to be
|
||||
* ready. Of course, aging is only employed when higher and lower
|
||||
* priority threads are runnable. The highest priority runnable
|
||||
* thread(s) are never skipped. */
|
||||
* yielding) but that's generally not desirable at all. On
|
||||
* the plus side, it, relatively to other threads, penalizes
|
||||
* excess yielding which is good if some high priority thread
|
||||
* is performing no useful work such as polling for a device
|
||||
* to be ready. Of course, aging is only employed when higher
|
||||
* and lower priority threads are runnable. The highest
|
||||
* priority runnable thread(s) are never skipped unless a
|
||||
* lower-priority process has aged sufficiently. Priorities
|
||||
* of REALTIME class are run strictly according to priority
|
||||
* thus are not subject to switchout due to lower-priority
|
||||
* processes aging; they must give up the processor by going
|
||||
* off the run list. */
|
||||
if (LIKELY(priority <= max) ||
|
||||
IF_NO_SKIP_YIELD( thread->skip_count == -1 || )
|
||||
(diff = priority - max, ++thread->skip_count > diff*diff))
|
||||
(priority > PRIORITY_REALTIME &&
|
||||
(diff = priority - max,
|
||||
++thread->skip_count > diff*diff)))
|
||||
{
|
||||
cores[core].running = thread;
|
||||
break;
|
||||
|
|
@ -2226,8 +2233,9 @@ unsigned int wakeup_thread(struct thread_entry **list)
|
|||
current = bl->wakeup_protocol(thread);
|
||||
}
|
||||
|
||||
if (current != NULL && thread->priority < current->priority
|
||||
IF_COP( && thread->core == current->core ))
|
||||
if (current != NULL &&
|
||||
IF_COP( thread->core == current->core && )
|
||||
find_first_set_bit(cores[current->core].rtr.mask) < current->priority)
|
||||
{
|
||||
/* Woken thread is higher priority and exists on the same CPU core;
|
||||
* recommend a task switch. Knowing if this is an interrupt call
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue