• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

include/nucleus/sched-rt.h

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 /* Priority scale for the RT scheduling class. */
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  * Builtin priorities shared by all core APIs.  Those APIs, namely
00037  * POSIX, native and RTDM, only use a sub-range of the available
00038  * priority levels from the RT scheduling class, in order to exhibit a
00039  * 1:1 mapping with Linux's SCHED_FIFO ascending priority scale
00040  * [1..99]. Non-core APIs with inverted priority scales (e.g. VxWorks,
00041  * VRTX), normalize the priority values internally when calling the
00042  * priority-sensitive services of the nucleus, so that they fit into
00043  * the RT priority scale.
00044  */
00045 #define XNSCHED_LOW_PRIO        0
00046 #define XNSCHED_HIGH_PRIO       99
00047 #define XNSCHED_IRQ_PRIO        XNSCHED_RT_MAX_PRIO /* For IRQ servers. */
00048 
00049 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00050 
00051 #if defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \
00052   XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS
00053 #error "RT class cannot use multi-level queue (too many priority levels)"
00054 #endif
00055 
00056 extern struct xnsched_class xnsched_class_rt;
00057 
00058 extern struct xnsched_class xnsched_class_idle;
00059 
00060 #define xnsched_class_default xnsched_class_rt
00061 
00062 static inline void __xnsched_rt_requeue(struct xnthread *thread)
00063 {
00064         sched_insertpql(&thread->sched->rt.runnable,
00065                         &thread->rlink, thread->cprio);
00066 }
00067 
00068 static inline void __xnsched_rt_enqueue(struct xnthread *thread)
00069 {
00070         sched_insertpqf(&thread->sched->rt.runnable,
00071                         &thread->rlink, thread->cprio);
00072 }
00073 
00074 static inline void __xnsched_rt_dequeue(struct xnthread *thread)
00075 {
00076         sched_removepq(&thread->sched->rt.runnable, &thread->rlink);
00077 }
00078 
00079 static inline struct xnthread *__xnsched_rt_pick(struct xnsched *sched)
00080 {
00081         struct xnpholder *h = sched_getpq(&sched->rt.runnable);
00082         return h ? link2thread(h, rlink) : NULL;
00083 }
00084 
00085 static inline void __xnsched_rt_setparam(struct xnthread *thread,
00086                                          const union xnsched_policy_param *p)
00087 {
00088         thread->cprio = p->rt.prio;
00089         if (xnthread_test_state(thread, XNSHADOW)) {
00090                 if (thread->cprio)
00091                         xnthread_clear_state(thread, XNOTHER);
00092                 else
00093                         xnthread_set_state(thread, XNOTHER);
00094         }
00095 }
00096 
00097 static inline void __xnsched_rt_getparam(struct xnthread *thread,
00098                                          union xnsched_policy_param *p)
00099 {
00100         p->rt.prio = thread->cprio;
00101 }
00102 
00103 static inline void __xnsched_rt_trackprio(struct xnthread *thread,
00104                                           const union xnsched_policy_param *p)
00105 {
00106         if (p)
00107                 __xnsched_rt_setparam(thread, p);
00108         else
00109                 thread->cprio = thread->bprio;
00110 }
00111 
00112 static inline void __xnsched_rt_forget(struct xnthread *thread)
00113 {
00114 }
00115 
00116 static inline int xnsched_rt_init_tcb(struct xnthread *thread)
00117 {
00118         return 0;
00119 }
00120 
00121 void xnsched_rt_tick(struct xnthread *curr);
00122 
00123 #ifdef CONFIG_XENO_OPT_PRIOCPL
00124 
00125 static inline struct xnthread *__xnsched_rt_push_rpi(struct xnsched *sched,
00126                                                      struct xnthread *thread)
00127 {
00128         sched_insertpqf(&sched->rt.relaxed, &thread->xlink, thread->cprio);
00129         return link2thread(sched_getheadpq(&sched->rt.relaxed), xlink);
00130 }
00131 
00132 static inline void __xnsched_rt_pop_rpi(struct xnthread *thread)
00133 {
00134         struct xnsched *sched = thread->rpi;
00135         sched_removepq(&sched->rt.relaxed, &thread->xlink);
00136 }
00137 
00138 static inline struct xnthread *__xnsched_rt_peek_rpi(struct xnsched *sched)
00139 {
00140         struct xnpholder *h = sched_getheadpq(&sched->rt.relaxed);
00141         return h ? link2thread(h, xlink) : NULL;
00142 }
00143 
00144 static inline void __xnsched_rt_suspend_rpi(struct xnthread *thread)
00145 {
00146 }
00147 
00148 static inline void __xnsched_rt_resume_rpi(struct xnthread *thread)
00149 {
00150 }
00151 
00152 #endif /* CONFIG_XENO_OPT_PRIOCPL */
00153 
00154 #endif /* __KERNEL__ || __XENO_SIM__ */
00155 
00156 #endif /* !_XENO_NUCLEUS_SCHED_RT_H */

Generated on Wed Nov 2 2011 18:01:06 for Xenomai API by  doxygen 1.7.1