diff --git a/base-hw/src/core/kernel/processor.cc b/base-hw/src/core/kernel/processor.cc index d1a2361391..4e277101b4 100644 --- a/base-hw/src/core/kernel/processor.cc +++ b/base-hw/src/core/kernel/processor.cc @@ -61,13 +61,17 @@ void Kernel::Processor_client::_schedule() { __processor->schedule(this); } void Kernel::Processor::schedule(Processor_client * const client) { - /* schedule processor client */ - _scheduler.insert(client); + if (_id != executing_id()) { - /* let the processor notice the change immediately */ - if (_id != executing_id() && !_ip_interrupt_pending) { - pic()->trigger_ip_interrupt(_id); - _ip_interrupt_pending = true; + /* remote add client and let target processor notice it if necessary */ + if (_scheduler.insert_and_check(client) && !_ip_interrupt_pending) { + pic()->trigger_ip_interrupt(_id); + _ip_interrupt_pending = true; + } + } else { + + /* add client locally */ + _scheduler.insert(client); } } diff --git a/base-hw/src/core/kernel/scheduler.h b/base-hw/src/core/kernel/scheduler.h index eb4ada4084..97b6caec01 100644 --- a/base-hw/src/core/kernel/scheduler.h +++ b/base-hw/src/core/kernel/scheduler.h @@ -279,6 +279,20 @@ class Kernel::Scheduler _items[i->priority()].insert_tail(i); } + /** + * Include item in scheduling and check wether an update is needed + * + * \param item targeted item + * + * \return wether the current occupant is out-dated after insertion + */ + bool insert_and_check(T * const item) + { + insert(item); + if (!_occupant) { return true; } + return item->priority() > _occupant->priority(); + } + /** * Exclude 'i' from scheduling */