]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/task_info.h
05e4db68c3d8ecb5c41d484236b567850c9bc995
[apple/xnu.git] / osfmk / mach / task_info.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 */
52 /*
53 * Machine-independent task information structures and definitions.
54 *
55 * The definitions in this file are exported to the user. The kernel
56 * will translate its internal data structures to these structures
57 * as appropriate.
58 *
59 */
60
61 #ifndef _MACH_TASK_INFO_H_
62 #define _MACH_TASK_INFO_H_
63
64 #include <mach/message.h>
65 #include <mach/machine/vm_types.h>
66 #include <mach/time_value.h>
67 #include <mach/policy.h>
68
69 #include <sys/cdefs.h>
70
71 /*
72 * Generic information structure to allow for expansion.
73 */
74 typedef natural_t task_flavor_t;
75 typedef integer_t *task_info_t; /* varying array of int */
76
77 #define TASK_INFO_MAX (1024) /* maximum array size */
78 typedef integer_t task_info_data_t[TASK_INFO_MAX];
79
80 /*
81 * Currently defined information structures.
82 */
83
84 #if __DARWIN_ALIGN_POWER
85 #pragma options align=power
86 #endif
87
88 #define TASK_BASIC_INFO_32 4 /* basic information */
89
90 struct task_basic_info_32 {
91 integer_t suspend_count; /* suspend count for task */
92 natural_t virtual_size; /* virtual memory size (bytes) */
93 natural_t resident_size; /* resident memory size (bytes) */
94 time_value_t user_time; /* total user run time for
95 terminated threads */
96 time_value_t system_time; /* total system run time for
97 terminated threads */
98 policy_t policy; /* default policy for new threads */
99 };
100 typedef struct task_basic_info_32 task_basic_info_32_data_t;
101 typedef struct task_basic_info_32 *task_basic_info_32_t;
102 #define TASK_BASIC_INFO_32_COUNT \
103 (sizeof(task_basic_info_32_data_t) / sizeof(natural_t))
104
105
106 #define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */
107
108 struct task_basic_info_64 {
109 integer_t suspend_count; /* suspend count for task */
110 mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
111 mach_vm_size_t resident_size; /* resident memory size (bytes) */
112 time_value_t user_time; /* total user run time for
113 terminated threads */
114 time_value_t system_time; /* total system run time for
115 terminated threads */
116 policy_t policy; /* default policy for new threads */
117 };
118 typedef struct task_basic_info_64 task_basic_info_64_data_t;
119 typedef struct task_basic_info_64 *task_basic_info_64_t;
120 #define TASK_BASIC_INFO_64_COUNT \
121 (sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
122
123
124 /* localized structure - cannot be safely passed between tasks of differing sizes */
125
126 struct task_basic_info {
127 integer_t suspend_count; /* suspend count for task */
128 vm_size_t virtual_size; /* virtual memory size (bytes) */
129 vm_size_t resident_size; /* resident memory size (bytes) */
130 time_value_t user_time; /* total user run time for
131 terminated threads */
132 time_value_t system_time; /* total system run time for
133 terminated threads */
134 policy_t policy; /* default policy for new threads */
135 };
136
137 typedef struct task_basic_info task_basic_info_data_t;
138 typedef struct task_basic_info *task_basic_info_t;
139 #define TASK_BASIC_INFO_COUNT \
140 (sizeof(task_basic_info_data_t) / sizeof(natural_t))
141 #if !defined(__LP64__)
142 #define TASK_BASIC_INFO TASK_BASIC_INFO_32
143 #else
144 #define TASK_BASIC_INFO TASK_BASIC_INFO_64
145 #endif
146
147
148
149 #define TASK_EVENTS_INFO 2 /* various event counts */
150
151 struct task_events_info {
152 integer_t faults; /* number of page faults */
153 integer_t pageins; /* number of actual pageins */
154 integer_t cow_faults; /* number of copy-on-write faults */
155 integer_t messages_sent; /* number of messages sent */
156 integer_t messages_received; /* number of messages received */
157 integer_t syscalls_mach; /* number of mach system calls */
158 integer_t syscalls_unix; /* number of unix system calls */
159 integer_t csw; /* number of context switches */
160 };
161 typedef struct task_events_info task_events_info_data_t;
162 typedef struct task_events_info *task_events_info_t;
163 #define TASK_EVENTS_INFO_COUNT ((mach_msg_type_number_t) \
164 (sizeof(task_events_info_data_t) / sizeof(natural_t)))
165
166 #define TASK_THREAD_TIMES_INFO 3 /* total times for live threads -
167 only accurate if suspended */
168
169 struct task_thread_times_info {
170 time_value_t user_time; /* total user run time for
171 live threads */
172 time_value_t system_time; /* total system run time for
173 live threads */
174 };
175
176 typedef struct task_thread_times_info task_thread_times_info_data_t;
177 typedef struct task_thread_times_info *task_thread_times_info_t;
178 #define TASK_THREAD_TIMES_INFO_COUNT ((mach_msg_type_number_t) \
179 (sizeof(task_thread_times_info_data_t) / sizeof(natural_t)))
180
181 #define TASK_ABSOLUTETIME_INFO 1
182
183 struct task_absolutetime_info {
184 uint64_t total_user; /* total time */
185 uint64_t total_system;
186 uint64_t threads_user; /* existing threads only */
187 uint64_t threads_system;
188 };
189
190 typedef struct task_absolutetime_info task_absolutetime_info_data_t;
191 typedef struct task_absolutetime_info *task_absolutetime_info_t;
192 #define TASK_ABSOLUTETIME_INFO_COUNT ((mach_msg_type_number_t) \
193 (sizeof (task_absolutetime_info_data_t) / sizeof (natural_t)))
194
195 #define TASK_SECURITY_TOKEN 13
196 #define TASK_SECURITY_TOKEN_COUNT ((mach_msg_type_number_t) \
197 (sizeof(security_token_t) / sizeof(natural_t)))
198
199 #define TASK_AUDIT_TOKEN 15
200 #define TASK_AUDIT_TOKEN_COUNT \
201 (sizeof(audit_token_t) / sizeof(natural_t))
202
203 #if __DARWIN_ALIGN_POWER
204 #pragma options align=reset
205 #endif
206
207
208 /*
209 * Obsolete interfaces.
210 */
211
212 #define TASK_SCHED_TIMESHARE_INFO 10
213 #define TASK_SCHED_RR_INFO 11
214 #define TASK_SCHED_FIFO_INFO 12
215
216 #define TASK_SCHED_INFO 14
217
218 #endif /* _MACH_TASK_INFO_H_ */