设置Zig中线程的核心亲和力

问题描述

在zig编程语言中为线程设置核心亲和力的建议方法是什么?在下面的文档中找不到类似的内容:

解决方法

设置核心相似性目前尚未在标准库中实现。

由于zig可以很容易地绑定到C函数,因此您只需使用@cImport()即可加载包含要使用的函数的特定于平台的C标头,例如sched.h用于sched_setaffinity(2)pthread.h用于pthread_setaffinity_np(3),在Linux上是winbase.h用于SetThreadAffinityMaskSetProcessAffinityMask在Windows中。 然后

@cImport()将为您提供一个包含所有这些功能的作用域,就好像它们是在Zig中定义的一样:https://ziglang.org/documentation/0.6.0/#Import-from-C-Header-File

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...