diff --git a/miosix/kernel/scheduler/control/control_scheduler.cpp b/miosix/kernel/scheduler/control/control_scheduler.cpp
index 3de8f97b0a89b1fe52f24c6bda9d2d2e702dd41f..a774893f404c3581610776ea79e700de2d9f047d 100644
--- a/miosix/kernel/scheduler/control/control_scheduler.cpp
+++ b/miosix/kernel/scheduler/control/control_scheduler.cpp
@@ -200,7 +200,8 @@ long long ControlScheduler::IRQgetNextPreemption()
 // Should be called when the current thread is the idle thread
 static inline void IRQsetNextPreemptionForIdle(){
     if (sleepingList->empty())
-        nextPreemption = numeric_limits<long long>::max();
+        //normally should happen unless an IRQ is set!
+        nextPreemption = numeric_limits<long long>::max(); 
     else
         nextPreemption = sleepingList->front()->wakeup_time;
     timer.IRQsetNextInterrupt(nextPreemption);
diff --git a/miosix/kernel/scheduler/control/control_scheduler_types.h b/miosix/kernel/scheduler/control/control_scheduler_types.h
index f68608788dea07d990d108c963aed965c3337858..3b4231563a9c8741f3e7922ef0d678fe9280b30e 100755
--- a/miosix/kernel/scheduler/control/control_scheduler_types.h
+++ b/miosix/kernel/scheduler/control/control_scheduler_types.h
@@ -125,21 +125,23 @@ private:
 
 inline bool operator <(ControlSchedulerPriority a, ControlSchedulerPriority b)
 {
-    return b.getRealtime() == 1 && a.getRealtime() != 1;
+    return (b.getRealtime() == 1 && a.getRealtime() != 1) ||
+            (a.getRealtime() != 1 && b.getRealtime() != 1 && a.get() < b.get());
 }
 
 inline bool operator>(ControlSchedulerPriority a, ControlSchedulerPriority b){
-    return a.getRealtime() == 1 && b.getRealtime() != 1;
+    return (a.getRealtime() == 1 && b.getRealtime() != 1) ||
+            (a.getRealtime() != 1 && b.getRealtime() != 1 && a.get() > b.get());
 }
 
 inline bool operator ==(ControlSchedulerPriority a, ControlSchedulerPriority b)
 {
-    return a.getRealtime() == b.getRealtime();
+    return (a.getRealtime() == b.getRealtime()) && (a.get() == b.get());
 }
 
 inline bool operator !=(ControlSchedulerPriority a, ControlSchedulerPriority b)
 {
-    return a.getRealtime() != b.getRealtime();
+    return (a.getRealtime() != b.getRealtime()) || (a.get()!= b.get());
 }
 
 struct ThreadsListItem : public IntrusiveListItem