attr 是线程属性变量;stacksize 则是设置的堆栈大小。 返回值0,-1分别表示成功与失败。 #include <iostream> #include <limits.h> #include <pthread.h> #include "error.h" using namespace std; int main(){ pthread_t thread; size_t stacksize; pthread_attr_t thread_attr; int ret; pthread_attr...
("hello from the thread\n"); pthread_exit(NULL); } int main() { int rc, stat; size_t s1; pthread_attr_t attr; pthread_t thid; rc = pthread_attr_init(&attr); if (rc == -1) { perror("error in pthread_attr_init"); exit(1); } s1 = 4096; rc = pthread_attr_setstack...
= 0) { // 设置失败,打印错误信息 perror("Error setting stack size"); // 清理资源 pthread_attr_destroy(&attr); return 1; } // 继续使用attr进行其他操作... // 清理资源 pthread_attr_destroy(&attr); return 0; } 在上面的代码中,我们首先初始化线程属性对象 attr,然后尝试使用 ...
If unsuccessful, pthread_attr_setstacksize() returns an error number to indicate the error.Example CELEBP12 /* CELEBP12 */ #define _OPEN_THREADS #include <stdio.h> #include <pthread.h> void *thread1(void *arg) { printf("hello from the thread\n"); pthread_exit(NULL); } int ...
pthread_attr_setstacksize() returns zero after completing successfully. Any other return value indicates that an error occurred. If the following condition occurs, the function fails and returns the corresponding value.EINVAL Description: The value of size is less than PTHREAD_STACK_MIN, or ...
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - mono_thread_platform_create_thread crashing with pthread_attr_setstacksize invalid argument error · dotnet/runtime@49e7fd5
If successful, pthread_attr_setstacksize() returns a value of0. If unsuccessful, pthread_attr_setstacksize() returns a value of -1. No errnos are defined for pthread_attr_setstacksize(). You should use perror() or strerror() to determine the cause of the error. ...
Codici di errore La sottoroutinepthread_attr_setstacksizeha esito negativo se si verifica quanto segue: Tabella 2. Codici di errore ElementoDescrizione EINVALIl parametroattrnon è valido oppure il valore del parametrostacksizesupera un limite imposto dal sistema. ...