2 * Copyright (c) 2000 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 <sys/appleapiopts.h>
68 #include <mach/boolean.h>
69 #include <mach/policy.h>
70 #include <mach/time_value.h>
71 #include <mach/machine/vm_types.h>
74 * Generic information structure to allow for expansion.
76 typedef natural_t thread_flavor_t
;
77 typedef integer_t
*thread_info_t
; /* varying array of int */
79 #define THREAD_INFO_MAX (1024) /* maximum array size */
80 typedef integer_t thread_info_data_t
[THREAD_INFO_MAX
];
83 * Currently defined information.
85 #define THREAD_BASIC_INFO 3 /* basic information */
87 struct thread_basic_info
{
88 time_value_t user_time
; /* user run time */
89 time_value_t system_time
; /* system run time */
90 integer_t cpu_usage
; /* scaled cpu usage percentage */
91 policy_t policy
; /* scheduling policy in effect */
92 integer_t run_state
; /* run state (see below) */
93 integer_t flags
; /* various flags (see below) */
94 integer_t suspend_count
; /* suspend count for thread */
95 integer_t sleep_time
; /* number of seconds that thread
99 typedef struct thread_basic_info thread_basic_info_data_t
;
100 typedef struct thread_basic_info
*thread_basic_info_t
;
101 #define THREAD_BASIC_INFO_COUNT \
102 (sizeof(thread_basic_info_data_t) / sizeof(natural_t))
105 * Scale factor for usage field.
108 #define TH_USAGE_SCALE 1000
111 * Thread run states (state field).
114 #define TH_STATE_RUNNING 1 /* thread is running normally */
115 #define TH_STATE_STOPPED 2 /* thread is stopped */
116 #define TH_STATE_WAITING 3 /* thread is waiting normally */
117 #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
119 #define TH_STATE_HALTED 5 /* thread is halted at a
123 * Thread flags (flags field).
125 #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
126 #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
128 #ifdef __APPLE_API_UNSTABLE
130 #define THREAD_SCHED_TIMESHARE_INFO 10
131 #define THREAD_SCHED_RR_INFO 11
132 #define THREAD_SCHED_FIFO_INFO 12
134 #endif /* __APPLE_API_UNSTABLE */
136 #endif /* _MACH_THREAD_INFO_H_ */