]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/thread_info.h
xnu-517.7.7.tar.gz
[apple/xnu.git] / osfmk / mach / thread_info.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
A
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.
1c79356b 11 *
e5568f75
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
1c79356b
A
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 * File: mach/thread_info
54 *
55 * Thread information structure and definitions.
56 *
57 * The defintions in this file are exported to the user. The kernel
58 * will translate its internal data structures to these structures
59 * as appropriate.
60 *
61 */
62
63#ifndef _MACH_THREAD_INFO_H_
64#define _MACH_THREAD_INFO_H_
65
9bccf70c
A
66#include <sys/appleapiopts.h>
67
1c79356b
A
68#include <mach/boolean.h>
69#include <mach/policy.h>
70#include <mach/time_value.h>
71#include <mach/machine/vm_types.h>
72
73/*
74 * Generic information structure to allow for expansion.
75 */
76typedef natural_t thread_flavor_t;
77typedef integer_t *thread_info_t; /* varying array of int */
78
79#define THREAD_INFO_MAX (1024) /* maximum array size */
80typedef integer_t thread_info_data_t[THREAD_INFO_MAX];
81
82/*
83 * Currently defined information.
84 */
85#define THREAD_BASIC_INFO 3 /* basic information */
86
87struct 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
96 has been sleeping */
97};
98
99typedef struct thread_basic_info thread_basic_info_data_t;
100typedef struct thread_basic_info *thread_basic_info_t;
101#define THREAD_BASIC_INFO_COUNT \
102 (sizeof(thread_basic_info_data_t) / sizeof(natural_t))
103
104/*
105 * Scale factor for usage field.
106 */
107
108#define TH_USAGE_SCALE 1000
109
110/*
111 * Thread run states (state field).
112 */
113
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
118 wait */
119#define TH_STATE_HALTED 5 /* thread is halted at a
120 clean point */
121
122/*
123 * Thread flags (flags field).
124 */
125#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
126#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
127
9bccf70c
A
128#ifdef __APPLE_API_UNSTABLE
129
1c79356b
A
130#define THREAD_SCHED_TIMESHARE_INFO 10
131#define THREAD_SCHED_RR_INFO 11
132#define THREAD_SCHED_FIFO_INFO 12
133
9bccf70c
A
134#endif /* __APPLE_API_UNSTABLE */
135
1c79356b 136#endif /* _MACH_THREAD_INFO_H_ */