Xenomai  3.0.5
sched-rt.h
1 /*
2  * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _COBALT_KERNEL_SCHED_RT_H
20 #define _COBALT_KERNEL_SCHED_RT_H
21 
22 #ifndef _COBALT_KERNEL_SCHED_H
23 #error "please don't include cobalt/kernel/sched-rt.h directly"
24 #endif
25 
31 /*
32  * Global priority scale for Xenomai's core scheduling class,
33  * available to SCHED_COBALT members.
34  */
35 #define XNSCHED_CORE_MIN_PRIO 0
36 #define XNSCHED_CORE_MAX_PRIO 259
37 #define XNSCHED_CORE_NR_PRIO \
38  (XNSCHED_CORE_MAX_PRIO - XNSCHED_CORE_MIN_PRIO + 1)
39 
40 /*
41  * Priority range for SCHED_FIFO, and all other classes Cobalt
42  * implements except SCHED_COBALT.
43  */
44 #define XNSCHED_FIFO_MIN_PRIO 1
45 #define XNSCHED_FIFO_MAX_PRIO 256
46 
47 #if XNSCHED_CORE_NR_PRIO > XNSCHED_CLASS_WEIGHT_FACTOR || \
48  (defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \
49  XNSCHED_CORE_NR_PRIO > XNSCHED_MLQ_LEVELS)
50 #error "XNSCHED_MLQ_LEVELS is too low"
51 #endif
52 
53 extern struct xnsched_class xnsched_class_rt;
54 
55 static inline void __xnsched_rt_requeue(struct xnthread *thread)
56 {
57  xnsched_addq(&thread->sched->rt.runnable, thread);
58 }
59 
60 static inline void __xnsched_rt_enqueue(struct xnthread *thread)
61 {
62  xnsched_addq_tail(&thread->sched->rt.runnable, thread);
63 }
64 
65 static inline void __xnsched_rt_dequeue(struct xnthread *thread)
66 {
67  xnsched_delq(&thread->sched->rt.runnable, thread);
68 }
69 
70 static inline void __xnsched_rt_setparam(struct xnthread *thread,
71  const union xnsched_policy_param *p)
72 {
73  thread->cprio = p->rt.prio;
74  if (!xnthread_test_state(thread, XNBOOST)) {
75 #ifdef CONFIG_XENO_OPT_SCHED_WEAK
76  xnthread_clear_state(thread, XNWEAK);
77 #else
78  if (thread->cprio)
79  xnthread_clear_state(thread, XNWEAK);
80  else
81  xnthread_set_state(thread, XNWEAK);
82 #endif
83  }
84 }
85 
86 static inline void __xnsched_rt_getparam(struct xnthread *thread,
87  union xnsched_policy_param *p)
88 {
89  p->rt.prio = thread->cprio;
90 }
91 
92 static inline void __xnsched_rt_trackprio(struct xnthread *thread,
93  const union xnsched_policy_param *p)
94 {
95  if (p)
96  __xnsched_rt_setparam(thread, p);
97  else
98  thread->cprio = thread->bprio;
99 }
100 
101 static inline void __xnsched_rt_forget(struct xnthread *thread)
102 {
103 }
104 
105 static inline int xnsched_rt_init_thread(struct xnthread *thread)
106 {
107  return 0;
108 }
109 
110 #ifdef CONFIG_XENO_OPT_SCHED_CLASSES
111 struct xnthread *xnsched_rt_pick(struct xnsched *sched);
112 #else
113 static inline struct xnthread *xnsched_rt_pick(struct xnsched *sched)
114 {
115  return xnsched_getq(&sched->rt.runnable);
116 }
117 #endif
118 
119 void xnsched_rt_tick(struct xnsched *sched);
120 
123 #endif /* !_COBALT_KERNEL_SCHED_RT_H */
#define XNBOOST
Undergoes a PIP boost.
Definition: thread.h:42
#define XNWEAK
Non real-time shadow (from the WEAK class)
Definition: thread.h:49
Scheduling information structure.
Definition: sched.h:57
struct xnsched_rt rt
Definition: sched.h:71