1 /*
2 * Mach Operating System
3 * Copyright (c) 1993 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: sched_policy_config.c,v $
29 * Revision 2.2 93/11/17 17:21:49 dbg
30 * Conditionalized on MACH_RT.
31 * [93/05/17 dbg]
32 *
33 * Created.
34 * [93/04/02 dbg]
35 *
36 */
37
38 #include <mach_rt.h>
39
40 /*
41 * List of scheduling policies.
42 *
43 * The list is kept as an array - scheduling policies are
44 * not (yet) added or removed while the system is running.
45 *
46 * Rank is determined by the position in the array. The
47 * higher-indexed policies have higher rank.
48 */
49
50 #include <kern/sched_policy.h>
51
52 extern struct sched_policy bg_sched_policy,
53 ts_sched_policy,
54 fp_sched_policy;
55 #if MACH_RT
56 extern struct sched_policy dm_sched_policy,
57 rm_sched_policy,
58 edf_sched_policy;
59 #endif
60
61 sched_policy_t sched_policy_array[] = {
62 &bg_sched_policy,
63 &ts_sched_policy,
64 &fp_sched_policy,
65 #if MACH_RT
66 &rm_sched_policy,
67 &dm_sched_policy,
68 &edf_sched_policy
69 #endif
70 };
71
72 int sched_policy_count = sizeof(sched_policy_array)
73 / sizeof(sched_policy_array[0]);
74
75 void
76 sched_policy_init(void)
77 {
78 /*
79 * Run down the list, assigning rank.
80 */
81 int i;
82
83 for (i = 0; i < sched_policy_count; i++)
84 sched_policy_array[i]->rank = i;
85 }
86
87 /*
88 * Lookup a scheduling policy by name.
89 */
90 sched_policy_t
91 sched_policy_lookup(
92 int policy)
93 {
94 int i;
95
96 for (i = 0; i < sched_policy_count; i++)
97 if (sched_policy_array[i]->name == policy)
98 return sched_policy_array[i];
99
100 return 0;
101 }
102
Cache object: 434f2b32b1870df3fc16841d0a76bbb7
|