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