]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/thread_group.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / kern / thread_group.h
CommitLineData
1c79356b 1/*
5ba3f43e 2 * Copyright (c) 2016 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
1c79356b 28
5ba3f43e
A
29/*
30 * Thread group support routines.
31 */
32#ifndef _KERN_THREAD_GROUP_H_
33#define _KERN_THREAD_GROUP_H_
1c79356b 34
5ba3f43e 35struct thread_group;
1c79356b 36
5ba3f43e 37#include <mach/thread_status.h> /* for proc_reg.h / CONFIG_THREAD_GROUPS */
1c79356b 38
f427ee49
A
39#ifndef CONFIG_THREAD_GROUPS
40#error "The platform must define CONFIG_THREAD_GROUPS to 0 or 1"
41#endif
1c79356b 42
f427ee49
A
43#if CONFIG_THREAD_GROUPS
44#include <kern/queue.h>
45#include <machine/machine_routines.h>
46
47#define THREAD_GROUP_MAX (CONFIG_TASK_MAX + 10)
48#define THREAD_GROUP_MAXNAME (16)
49
50#define THREAD_GROUP_SYSTEM 0 // kernel (-VM) + launchd
51#define THREAD_GROUP_BACKGROUND 1 // background daemons
52#define THREAD_GROUP_ADAPTIVE 2 // adaptive daemons
53#define THREAD_GROUP_VM 3 // kernel VM threads
54#define THREAD_GROUP_IO_STORAGE 4 // kernel io storage threads
55#define THREAD_GROUP_PERF_CONTROLLER 5 // kernel CLPC threads
56
57#define THREAD_GROUP_INVALID UINT64_MAX
58
59/* Thread group flags */
60#define THREAD_GROUP_FLAGS_EFFICIENT 0x1
61#define THREAD_GROUP_FLAGS_UI_APP 0x2
62#define THREAD_GROUP_FLAGS_SMP_RESTRICT 0x4
63#define THREAD_GROUP_FLAGS_VALID (THREAD_GROUP_FLAGS_EFFICIENT | THREAD_GROUP_FLAGS_UI_APP | THREAD_GROUP_FLAGS_SMP_RESTRICT)
64
65__BEGIN_DECLS
66
67void thread_group_init(void);
68void thread_group_resync(boolean_t create);
69struct thread_group *thread_group_create_and_retain(void);
70void thread_group_init_thread(thread_t t, task_t task);
71void thread_group_set_name(struct thread_group *tg, const char *name);
72void thread_group_flags_update_lock(void);
73void thread_group_flags_update_unlock(void);
74void thread_group_set_flags(struct thread_group *tg, uint64_t flags);
75void thread_group_clear_flags(struct thread_group *tg, uint64_t flags);
76void thread_group_set_flags_locked(struct thread_group *tg, uint64_t flags);
77void thread_group_clear_flags_locked(struct thread_group *tg, uint64_t flags);
78struct thread_group *thread_group_find_by_name_and_retain(char *name);
79struct thread_group *thread_group_find_by_id_and_retain(uint64_t id);
80struct thread_group *thread_group_retain(struct thread_group *tg);
81void thread_group_release(struct thread_group *tg);
82struct thread_group *thread_group_get(thread_t t);
83struct thread_group *thread_group_get_home_group(thread_t t);
84void thread_group_set_bank(thread_t t, struct thread_group *tg);
85uint64_t thread_group_get_id(struct thread_group *tg);
86uint32_t thread_group_count(void);
87const char * thread_group_get_name(struct thread_group *tg);
88void * thread_group_get_machine_data(struct thread_group *tg);
89uint32_t thread_group_machine_data_size(void);
90cluster_type_t thread_group_recommendation(struct thread_group *tg);
91
92typedef void (*thread_group_iterate_fn_t)(void*, int, struct thread_group *);
93kern_return_t thread_group_iterate_stackshot(thread_group_iterate_fn_t callout, void *arg);
c3c9b80d 94uint32_t thread_group_get_flags(struct thread_group *);
f427ee49
A
95boolean_t thread_group_smp_restricted(struct thread_group *tg);
96void thread_group_update_recommendation(struct thread_group *tg, cluster_type_t new_recommendation);
97
98void thread_set_work_interval_thread_group(thread_t t, struct thread_group *tg, bool auto_join);
99
100#if XNU_KERNEL_PRIVATE
101void thread_group_vm_add(void);
102#endif
103
104__END_DECLS
105
106#endif /* CONFIG_THREAD_GROUPS */
91447636 107
5ba3f43e 108#endif // _KERN_THREAD_GROUP_H_