Skip to content
Snippets Groups Projects
Commit 60117527 authored by Federico's avatar Federico
Browse files

Fix comparison operator for control scheduler, and add operator <= and >=

parent e248e89d
No related branches found
No related tags found
No related merge requests found
...@@ -139,9 +139,11 @@ inline bool operator<(ControlSchedulerPriority a, ControlSchedulerPriority b) ...@@ -139,9 +139,11 @@ inline bool operator<(ControlSchedulerPriority a, ControlSchedulerPriority b)
#ifdef SCHED_CONTROL_MULTIBURST #ifdef SCHED_CONTROL_MULTIBURST
//rule 1) Idle thread should be always preempted by any thread! //rule 1) Idle thread should be always preempted by any thread!
//rule 2) Only REALTIME_PRIORITY_IMMEDIATE threads can preempt other threads //rule 2) Only REALTIME_PRIORITY_IMMEDIATE threads can preempt other threads
//right away, for other real-time priorities, the scheduler does not // a\b idle normal immedaite
//require to be called before the end of the current burst! // idle f T T
return a.get()==-1 || // normal f f T
// immediate f f f
return (a.get()==-1 && b.get()!=-1) ||
(a.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE && (a.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE &&
b.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE); b.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE);
#else #else
...@@ -149,10 +151,29 @@ inline bool operator<(ControlSchedulerPriority a, ControlSchedulerPriority b) ...@@ -149,10 +151,29 @@ inline bool operator<(ControlSchedulerPriority a, ControlSchedulerPriority b)
#endif #endif
} }
inline bool operator<=(ControlSchedulerPriority a, ControlSchedulerPriority b)
{
#ifdef SCHED_CONTROL_MULTIBURST
// a\b idle normal immedaite
// idle T T T
// normal f T T
// immediate f f T
return (a.get()==-1 || b.get()!=-1) &&
(a.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE ||
b.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE);
#else
return a.get()<=b.get();
#endif
}
inline bool operator>(ControlSchedulerPriority a, ControlSchedulerPriority b) inline bool operator>(ControlSchedulerPriority a, ControlSchedulerPriority b)
{ {
#ifdef SCHED_CONTROL_MULTIBURST #ifdef SCHED_CONTROL_MULTIBURST
return b.get()==-1 || // a\b idle normal immedaite
// idle f f f
// normal T f f
// immediate T T f
return (a.get()!=-1 && b.get()==-1) ||
(a.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE && (a.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE &&
b.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE); b.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE);
#else #else
...@@ -160,6 +181,21 @@ inline bool operator>(ControlSchedulerPriority a, ControlSchedulerPriority b) ...@@ -160,6 +181,21 @@ inline bool operator>(ControlSchedulerPriority a, ControlSchedulerPriority b)
#endif #endif
} }
inline bool operator>=(ControlSchedulerPriority a, ControlSchedulerPriority b)
{
#ifdef SCHED_CONTROL_MULTIBURST
// a\b idle normal immedaite
// idle T f f
// normal T T f
// immediate T T T
return (a.get()!=-1 || b.get()==-1) &&
(a.getRealtime()==ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE ||
b.getRealtime()!=ControlRealtimePriority::REALTIME_PRIORITY_IMMEDIATE);
#else
return a.get()>=b.get();
#endif
}
inline bool operator==(ControlSchedulerPriority a, ControlSchedulerPriority b) inline bool operator==(ControlSchedulerPriority a, ControlSchedulerPriority b)
{ {
#ifdef SCHED_CONTROL_MULTIBURST #ifdef SCHED_CONTROL_MULTIBURST
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment