Xenomai  3.0.8
sched-quota.h
1 /*
2  * Copyright (C) 2013 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_QUOTA_H
20 #define _COBALT_KERNEL_SCHED_QUOTA_H
21 
22 #ifndef _COBALT_KERNEL_SCHED_H
23 #error "please don't include cobalt/kernel/sched-quota.h directly"
24 #endif
25 
31 #ifdef CONFIG_XENO_OPT_SCHED_QUOTA
32 
33 #define XNSCHED_QUOTA_MIN_PRIO 1
34 #define XNSCHED_QUOTA_MAX_PRIO 255
35 #define XNSCHED_QUOTA_NR_PRIO \
36  (XNSCHED_QUOTA_MAX_PRIO - XNSCHED_QUOTA_MIN_PRIO + 1)
37 
38 extern struct xnsched_class xnsched_class_quota;
39 
40 struct xnsched_quota_group {
41  struct xnsched *sched;
42  xnticks_t quota_ns;
43  xnticks_t quota_peak_ns;
44  xnticks_t run_start_ns;
45  xnticks_t run_budget_ns;
46  xnticks_t run_credit_ns;
47  struct list_head members;
48  struct list_head expired;
49  struct list_head next;
50  int nr_active;
51  int nr_threads;
52  int tgid;
53  int quota_percent;
54  int quota_peak_percent;
55 };
56 
57 struct xnsched_quota {
58  xnticks_t period_ns;
59  struct xntimer refill_timer;
60  struct xntimer limit_timer;
61  struct list_head groups;
62 };
63 
64 static inline int xnsched_quota_init_thread(struct xnthread *thread)
65 {
66  thread->quota = NULL;
67  INIT_LIST_HEAD(&thread->quota_expired);
68 
69  return 0;
70 }
71 
72 int xnsched_quota_create_group(struct xnsched_quota_group *tg,
73  struct xnsched *sched,
74  int *quota_sum_r);
75 
76 int xnsched_quota_destroy_group(struct xnsched_quota_group *tg,
77  int force,
78  int *quota_sum_r);
79 
80 void xnsched_quota_set_limit(struct xnsched_quota_group *tg,
81  int quota_percent, int quota_peak_percent,
82  int *quota_sum_r);
83 
84 struct xnsched_quota_group *
85 xnsched_quota_find_group(struct xnsched *sched, int tgid);
86 
87 int xnsched_quota_sum_all(struct xnsched *sched);
88 
89 #endif /* !CONFIG_XENO_OPT_SCHED_QUOTA */
90 
93 #endif /* !_COBALT_KERNEL_SCHED_QUOTA_H */
Scheduling information structure.
Definition: sched.h:58