MySQL 8.0.33
Source Code Documentation
thread_attrs_api.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef RESOURCEGROUPS_PLATFORM_THREAD_ATTRS_API_H_
24#define RESOURCEGROUPS_PLATFORM_THREAD_ATTRS_API_H_
25
26#include <cinttypes> // uint32_t
27#include <vector> // std::vector
28
29#include "my_thread_os_id.h" // my_thread_os_id
30
31namespace resourcegroups {
32namespace platform {
33using cpu_id_t = uint32_t;
34
35/**
36 Check if platform supports binding CPUS to thread.
37
38 @returns true if platform supports CPU binding else false.
39*/
40
42
43/**
44 Bind current thread to run on CPU cpu_id.
45
46 @param cpu_id ID of the CPU.
47
48 @returns false if binding was successful else true.
49*/
50
51bool bind_to_cpu(cpu_id_t cpu_id);
52
53/**
54 Bind thread specified by thread_id to run on CPU cpu_id.
55
56 @param cpu_id ID of CPU.
57 @param thread_id OS ID of the thread.
58
59 @returns true if binding was unsuccessful else false.
60*/
61
63
64/**
65 Bind current thread to run on the list of CPUS specified in cpu_ids.
66
67 @param cpu_ids List of CPU IDs to bind current thread.
68
69 @returns false if binding was successful else true.
70*/
71
72bool bind_to_cpus(const std::vector<cpu_id_t> &cpu_ids);
73
74/**
75 Bind thread specified by thread_id to run on list of CPUs specified by
76 cpu_ids.
77
78 @param cpu_ids List of CPU IDs to bind the thread.
79 @param thread_id OS ID of thread.
80
81 @returns false if binding was successful else true.
82*/
83
84bool bind_to_cpus(const std::vector<cpu_id_t> &cpu_ids,
86
87/**
88 Unbind current thread to run on all CPUs.
89
90 @returns true if unbind was unsuccessful else false.
91*/
92
93bool unbind_thread();
94
95/**
96 Unbind thread specified by thread_id to run on all CPUs.
97
98 @returns true if unbind was unsuccessful else false.
99*/
100
102
103/**
104 Get priority of thread specified by thread_id.
105
106 @param thread_id OS ID of the thread.
107
108 @returns an int indicating priority of the thread.
109*/
110
112
113/**
114 Set priority of current thread.
115
116 @param priority Priority to set to.
117
118 @returns true if call was unsuccessful else false.
119*/
120
122
123/**
124 Set priority of thread specified by thread_id.
125
126 @param priority Priority to set to.
127 @param thread_id OS ID of the thread.
128
129 @returns true if call was unsuccessful else false.
130*/
131
133
134/**
135 Find number of VCPUs as seen by the current process based on the
136 affinity between each process and VCPU.
137*/
138uint32_t num_vcpus_using_affinity();
139
140/**
141 Get the number of VCPUS based on system configuration.
142*/
143
144uint32_t num_vcpus_using_config();
145
146/**
147 Get the number of VCPU.
148*/
149
150uint32_t num_vcpus();
151
152/**
153 Check if thread priority setting is allowed on the platform or not.
154
155 @returns true if thread priority setting is allowed else false.
156*/
157
159
160/**
161 Check if thread priority value is valid.
162
163 @returns true if thread priority value is valid else false.
164*/
165
167
168/**
169 Get the minimum priority value
170
171 @returns int indicating minimum priority value
172*/
173
175
176/**
177 Get the maximum priority value
178
179 @returns int indicating max priority value.
180*/
181
183} // namespace platform
184} // namespace resourcegroups
185#endif // RESOURCEGROUPS_PLATFORM_THREAD_ATTRS_API_H_
static my_thread_id thread_id
Definition: my_thr_init.cc:62
Portable wrapper for gettid().
unsigned long long my_thread_os_id_t
Definition: my_thread_os_id.h:47
int min_thread_priority_value()
Get the minimum priority value.
Definition: thread_attrs_api_common.cc:33
uint32_t cpu_id_t
Definition: thread_attrs_api.h:33
bool set_thread_priority(int priority)
Set priority of current thread.
Definition: thread_attrs_api_apple.cc:75
bool is_valid_thread_priority(int priority)
Check if thread priority value is valid.
Definition: thread_attrs_api_common.cc:29
int max_thread_priority_value()
Get the maximum priority value.
Definition: thread_attrs_api_common.cc:35
bool bind_to_cpu(cpu_id_t cpu_id)
Bind current thread to run on CPU cpu_id.
Definition: thread_attrs_api_apple.cc:40
uint32_t num_vcpus()
Get the number of VCPU.
Definition: thread_attrs_api_common.cc:37
int thread_priority(my_thread_os_id_t thread_id)
Get priority of thread specified by thread_id.
Definition: thread_attrs_api_apple.cc:70
bool bind_to_cpus(const std::vector< cpu_id_t > &cpu_ids)
Bind current thread to run on the list of CPUS specified in cpu_ids.
Definition: thread_attrs_api_apple.cc:50
bool is_platform_supported()
Check if platform supports binding CPUS to thread.
Definition: thread_attrs_api_apple.cc:38
uint32_t num_vcpus_using_config()
Get the number of VCPUS based on system configuration.
Definition: thread_attrs_api_apple.cc:87
bool can_thread_priority_be_set()
Check if thread priority setting is allowed on the platform or not.
Definition: thread_attrs_api_apple.cc:96
uint32_t num_vcpus_using_affinity()
Find number of VCPUs as seen by the current process based on the affinity between each process and VC...
Definition: thread_attrs_api_apple.cc:85
bool unbind_thread()
Unbind current thread to run on all CPUs.
Definition: thread_attrs_api_apple.cc:60
Definition: dd_resource_group.h:28
required uint32 priority
Definition: replication_group_member_actions.proto:34