2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * File: mach/thread_info
55 * Thread information structure and definitions.
57 * The defintions in this file are exported to the user. The kernel
58 * will translate its internal data structures to these structures
63 #ifndef _MACH_THREAD_INFO_H_
64 #define _MACH_THREAD_INFO_H_
66 #include <mach/boolean.h>
67 #include <mach/policy.h>
68 #include <mach/time_value.h>
69 #include <mach/message.h>
70 #include <mach/machine/vm_types.h>
73 * Generic information structure to allow for expansion.
75 typedef natural_t thread_flavor_t
;
76 typedef integer_t
*thread_info_t
; /* varying array of int */
78 #define THREAD_INFO_MAX (1024) /* maximum array size */
79 typedef integer_t thread_info_data_t
[THREAD_INFO_MAX
];
82 * Currently defined information.
84 #define THREAD_BASIC_INFO 3 /* basic information */
86 struct thread_basic_info
{
87 time_value_t user_time
; /* user run time */
88 time_value_t system_time
; /* system run time */
89 integer_t cpu_usage
; /* scaled cpu usage percentage */
90 policy_t policy
; /* scheduling policy in effect */
91 integer_t run_state
; /* run state (see below) */
92 integer_t flags
; /* various flags (see below) */
93 integer_t suspend_count
; /* suspend count for thread */
94 integer_t sleep_time
; /* number of seconds that thread
98 typedef struct thread_basic_info thread_basic_info_data_t
;
99 typedef struct thread_basic_info
*thread_basic_info_t
;
100 #define THREAD_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
101 (sizeof(thread_basic_info_data_t) / sizeof(natural_t)))
104 * Scale factor for usage field.
107 #define TH_USAGE_SCALE 1000
110 * Thread run states (state field).
113 #define TH_STATE_RUNNING 1 /* thread is running normally */
114 #define TH_STATE_STOPPED 2 /* thread is stopped */
115 #define TH_STATE_WAITING 3 /* thread is waiting normally */
116 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
118 #define TH_STATE_HALTED 5 /* thread is halted at a
122 * Thread flags (flags field).
124 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
125 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
128 * Obsolete interfaces.
131 #define THREAD_SCHED_TIMESHARE_INFO 10
132 #define THREAD_SCHED_RR_INFO 11
133 #define THREAD_SCHED_FIFO_INFO 12
135 #endif /* _MACH_THREAD_INFO_H_ */