Go to the documentation of this file.00001
00023 #ifndef _XENO_NUCLEUS_SCHED_RT_H
00024 #define _XENO_NUCLEUS_SCHED_RT_H
00025
00026 #ifndef _XENO_NUCLEUS_SCHED_H
00027 #error "please don't include nucleus/sched-rt.h directly"
00028 #endif
00029
00030
00031 #define XNSCHED_RT_MIN_PRIO 0
00032 #define XNSCHED_RT_MAX_PRIO 257
00033 #define XNSCHED_RT_NR_PRIO (XNSCHED_RT_MAX_PRIO - XNSCHED_RT_MIN_PRIO + 1)
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define XNSCHED_LOW_PRIO 0
00046 #define XNSCHED_HIGH_PRIO 99
00047 #define XNSCHED_IRQ_PRIO XNSCHED_RT_MAX_PRIO
00048
00049 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00050
00051 #if XNSCHED_RT_NR_PRIO > XNSCHED_CLASS_MAX_PRIO || \
00052 (defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \
00053 XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS)
00054 #error "RT class has too many priority levels"
00055 #endif
00056
00057 extern struct xnsched_class xnsched_class_rt;
00058
00059 extern struct xnsched_class xnsched_class_idle;
00060
00061 #define xnsched_class_default xnsched_class_rt
00062
00063 static inline void __xnsched_rt_requeue(struct xnthread *thread)
00064 {
00065 sched_insertpql(&thread->sched->rt.runnable,
00066 &thread->rlink, thread->cprio);
00067 }
00068
00069 static inline void __xnsched_rt_enqueue(struct xnthread *thread)
00070 {
00071 sched_insertpqf(&thread->sched->rt.runnable,
00072 &thread->rlink, thread->cprio);
00073 }
00074
00075 static inline void __xnsched_rt_dequeue(struct xnthread *thread)
00076 {
00077 sched_removepq(&thread->sched->rt.runnable, &thread->rlink);
00078 }
00079
00080 static inline struct xnthread *__xnsched_rt_pick(struct xnsched *sched)
00081 {
00082 struct xnpholder *h = sched_getpq(&sched->rt.runnable);
00083 return h ? link2thread(h, rlink) : NULL;
00084 }
00085
00086 static inline void __xnsched_rt_setparam(struct xnthread *thread,
00087 const union xnsched_policy_param *p)
00088 {
00089 thread->cprio = p->rt.prio;
00090 if (xnthread_test_state(thread, XNSHADOW | XNBOOST) == XNSHADOW) {
00091 if (thread->cprio)
00092 xnthread_clear_state(thread, XNOTHER);
00093 else
00094 xnthread_set_state(thread, XNOTHER);
00095 }
00096 }
00097
00098 static inline void __xnsched_rt_getparam(struct xnthread *thread,
00099 union xnsched_policy_param *p)
00100 {
00101 p->rt.prio = thread->cprio;
00102 }
00103
00104 static inline void __xnsched_rt_trackprio(struct xnthread *thread,
00105 const union xnsched_policy_param *p)
00106 {
00107 if (p)
00108 __xnsched_rt_setparam(thread, p);
00109 else
00110 thread->cprio = thread->bprio;
00111 }
00112
00113 static inline void __xnsched_rt_forget(struct xnthread *thread)
00114 {
00115 }
00116
00117 static inline int xnsched_rt_init_tcb(struct xnthread *thread)
00118 {
00119 return 0;
00120 }
00121
00122 void xnsched_rt_tick(struct xnthread *curr);
00123
00124 #ifdef CONFIG_XENO_OPT_PRIOCPL
00125
00126 static inline struct xnthread *__xnsched_rt_push_rpi(struct xnsched *sched,
00127 struct xnthread *thread)
00128 {
00129 sched_insertpqf(&sched->rt.relaxed, &thread->xlink, thread->cprio);
00130 return link2thread(sched_getheadpq(&sched->rt.relaxed), xlink);
00131 }
00132
00133 static inline void __xnsched_rt_pop_rpi(struct xnthread *thread)
00134 {
00135 struct xnsched *sched = thread->rpi;
00136 sched_removepq(&sched->rt.relaxed, &thread->xlink);
00137 }
00138
00139 static inline struct xnthread *__xnsched_rt_peek_rpi(struct xnsched *sched)
00140 {
00141 struct xnpholder *h = sched_getheadpq(&sched->rt.relaxed);
00142 return h ? link2thread(h, xlink) : NULL;
00143 }
00144
00145 static inline void __xnsched_rt_suspend_rpi(struct xnthread *thread)
00146 {
00147 }
00148
00149 static inline void __xnsched_rt_resume_rpi(struct xnthread *thread)
00150 {
00151 }
00152
00153 #endif
00154
00155 #endif
00156
00157 #endif