summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-04-18 09:43:59 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-04-18 09:43:59 +0000
commitd6cd1bc58e61d755aefcc66bcde351d140f81e2e (patch)
tree569ad510b5b14a10c01eeb318946123dfa6e51bf /firmware
parent1a10c75c03b721203d5994c53be2b3fc7c9eccea (diff)
downloadrockbox-d6cd1bc58e61d755aefcc66bcde351d140f81e2e.tar.gz
rockbox-d6cd1bc58e61d755aefcc66bcde351d140f81e2e.zip
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/thread.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index 7c2cfb23e9..1e20181c75 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -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