diff options
Diffstat (limited to 'firmware/thread.c')
| -rw-r--r-- | firmware/thread.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/firmware/thread.c b/firmware/thread.c index 7c2cfb2..1e20181 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 |