gpt4 book ai didi

c - 将线程策略设置为 SCHED_RR 时出现未知错误

转载 作者:行者123 更新时间:2023-11-30 14:50:40 31 4
gpt4 key购买 nike

尝试将线程的调度策略设置为 SCHED_RR 时,我收到未知错误代码(实际上是 48)。

这是我的代码示例:

#include <sched.h>
#include <pthread.h>
#include <stdio.h>

int main() {
pthread_attr_t attr;

pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
int ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
printf("ret: %s\n", strerror(ret));

return 0;
}

追踪:

ret: Unknown error

为什么会这样呢?这不像我在其他问题中看到的那样是 EPERM。

我在 Windows 7 上使用 cygwin。

最佳答案

如果您阅读了 cygwin 中 pthread 的文档:

https://sourceware.org/pthreads-win32/announcement.html

您可以看到仅支持 SCHED_OTHER:

pthread_attr_setschedpolicy (only supports SCHED_OTHER)

关于c - 将线程策略设置为 SCHED_RR 时出现未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48881602/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com