- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图找到UNIX计算机上每个进程的最大线程数,并编写了以下代码以使用sysconf:
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main() {
errno = 0;
long maxThreads = sysconf(_SC_THREAD_THREADS_MAX);
if (maxThreads == -1 && errno == 0)
{
printf("the variable corresponding to _SC_THREAD_THREADS_MAX "
"is associated with functionality that is not "
"supported by the system\n");
exit(1);
}
if (maxThreads == -1)
{
printf("errno: %d\n", errno);
exit(1);
}
printf ("max num threads per process: %ld\n", maxThreads);
exit(0);
}
最佳答案
根据我在Mac OSX 10.7.X上的sysconf
手册:
If the call to sysconf() is not successful, -1 is returned and errno is set appropriately. Otherwise, if the variable is associated with functionality that is not supported, -1 is returned and errno is not modified. Otherwise, the current variable value is returned.
If name is invalid, -1 is returned, and errno is set to EINVAL. Otherwise, the value returned is the value of the system resource and errno is not changed. In the case of options, a positive value is returned if a queried option is available, and -1 if it is not. In the case of limits, -1 means that there is no definite limit.
_SC_THREAD_THREADS_MAX
在该体系结构上不是有效的sysconfig变量,或者可能没有限制。也许在其他架构上还有
-1
的另一种定义。您必须查看要尝试使用的每种体系结构的手册。
_SC_THREAD_THREADS_MAX
无效,那么您可能要尝试使用进程而不是线程。也许有一个最大进程设置,这也意味着最大线程数。
关于c - 每个进程的最大线程数-sysconf(_SC_THREAD_THREADS_MAX)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9572647/
我试图找到UNIX计算机上每个进程的最大线程数,并编写了以下代码以使用sysconf: #include #include #include #include #include int ma
我是一名优秀的程序员,十分优秀!