aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authordaomingq <daoming.qiu@intel.com>2022-10-21 21:18:10 +0800
committerGitHub <noreply@github.com>2022-10-21 09:18:10 -0400
commite900006642a5e8d4ab27a8760afcc03136f0dd8f (patch)
tree571752af5385e116be3cdc4e47c66a1c3211b418 /docs/src
parent357d28a256bfe11d9a4a9b2cf4f28d97b42ba68d (diff)
downloadlibuv-e900006642a5e8d4ab27a8760afcc03136f0dd8f.tar.gz
libuv-e900006642a5e8d4ab27a8760afcc03136f0dd8f.zip
thread: add support for affinity (#3774)
Backported thread affinity feature and related dependency commits from master. It will add support for those APIs: uv_cpumask_size, uv_thread_setaffinity, uv_thread_getaffinity. The supported platforms are Linux, Freebsd, and Windows. Empty implementations (returning UV_ENOTSUP) on non-supported platforms (such as OS X and AIX).
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/misc.rst7
-rw-r--r--docs/src/threading.rst31
2 files changed, 38 insertions, 0 deletions
diff --git a/docs/src/misc.rst b/docs/src/misc.rst
index f6d26efc..423ef84c 100644
--- a/docs/src/misc.rst
+++ b/docs/src/misc.rst
@@ -365,6 +365,13 @@ API
Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`.
+.. c:function:: int uv_cpumask_size(void)
+
+ Returns the maximum size of the mask used for process/thread affinities,
+ or ``UV_ENOTSUP`` if affinities are not supported on the current platform.
+
+ .. versionadded:: 1.45.0
+
.. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count)
Gets address information about the network interfaces on the system. An
diff --git a/docs/src/threading.rst b/docs/src/threading.rst
index 7ca1d4b7..ca9fb0ce 100644
--- a/docs/src/threading.rst
+++ b/docs/src/threading.rst
@@ -88,6 +88,37 @@ Threads
.. versionadded:: 1.26.0
+.. c:function:: int uv_thread_setaffinity(uv_thread_t* tid, char* cpumask, char* oldmask, size_t mask_size)
+
+ Sets the specified thread's affinity to cpumask, which is specified in
+ bytes. Optionally returning the previous affinity setting in oldmask.
+ On Unix, uses :man:`pthread_getaffinity_np(3)` to get the affinity setting
+ and maps the cpu_set_t to bytes in oldmask. Then maps the bytes in cpumask
+ to a cpu_set_t and uses :man:`pthread_setaffinity_np(3)`. On Windows, maps
+ the bytes in cpumask to a bitmask and uses SetThreadAffinityMask() which
+ returns the previous affinity setting.
+
+ The mask_size specifies the number of entries (bytes) in cpumask / oldmask,
+ and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
+
+ .. note::
+ Thread affinity setting is not atomic on Windows. Unsupported on macOS.
+
+ .. versionadded:: 1.45.0
+
+.. c:function:: int uv_thread_getaffinity(uv_thread_t* tid, char* cpumask, size_t mask_size)
+
+ Gets the specified thread's affinity setting. On Unix, this maps the
+ cpu_set_t returned by :man:`pthread_getaffinity_np(3)` to bytes in cpumask.
+
+ The mask_size specifies the number of entries (bytes) in cpumask,
+ and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
+
+ .. note::
+ Thread affinity getting is not atomic on Windows. Unsupported on macOS.
+
+ .. versionadded:: 1.45.0
+
.. c:function:: uv_thread_t uv_thread_self(void)
.. c:function:: int uv_thread_join(uv_thread_t *tid)
.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)