2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
56 * File: mach/thread_info
58 * Thread information structure and definitions.
60 * The defintions in this file are exported to the user. The kernel
61 * will translate its internal data structures to these structures
66 #ifndef _MACH_THREAD_INFO_H_
67 #define _MACH_THREAD_INFO_H_
69 #include <sys/appleapiopts.h>
71 #include <mach/boolean.h>
72 #include <mach/policy.h>
73 #include <mach/time_value.h>
74 #include <mach/machine/vm_types.h>
77 * Generic information structure to allow for expansion.
79 typedef natural_t thread_flavor_t
;
80 typedef integer_t
*thread_info_t
; /* varying array of int */
82 #define THREAD_INFO_MAX (1024) /* maximum array size */
83 typedef integer_t thread_info_data_t
[THREAD_INFO_MAX
];
86 * Currently defined information.
88 #define THREAD_BASIC_INFO 3 /* basic information */
90 struct thread_basic_info
{
91 time_value_t user_time
; /* user run time */
92 time_value_t system_time
; /* system run time */
93 integer_t cpu_usage
; /* scaled cpu usage percentage */
94 policy_t policy
; /* scheduling policy in effect */
95 integer_t run_state
; /* run state (see below) */
96 integer_t flags
; /* various flags (see below) */
97 integer_t suspend_count
; /* suspend count for thread */
98 integer_t sleep_time
; /* number of seconds that thread
102 typedef struct thread_basic_info thread_basic_info_data_t
;
103 typedef struct thread_basic_info
*thread_basic_info_t
;
104 #define THREAD_BASIC_INFO_COUNT \
105 (sizeof(thread_basic_info_data_t) / sizeof(natural_t))
108 * Scale factor for usage field.
111 #define TH_USAGE_SCALE 1000
114 * Thread run states (state field).
117 #define TH_STATE_RUNNING 1 /* thread is running normally */
118 #define TH_STATE_STOPPED 2 /* thread is stopped */
119 #define TH_STATE_WAITING 3 /* thread is waiting normally */
120 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
122 #define TH_STATE_HALTED 5 /* thread is halted at a
126 * Thread flags (flags field).
128 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
129 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
131 #ifdef __APPLE_API_UNSTABLE
133 #define THREAD_SCHED_TIMESHARE_INFO 10
134 #define THREAD_SCHED_RR_INFO 11
135 #define THREAD_SCHED_FIFO_INFO 12
137 #endif /* __APPLE_API_UNSTABLE */
139 #endif /* _MACH_THREAD_INFO_H_ */