as400/IBM 上的 pthread 错误代码 3029 我?

pthread error code 3029 on the as400/IBM I?

我有以下 C 源代码:

#define _MULTI_THREADED
#include <pthread.h>
#include <stdio.h>

void* threadfunc(void* parm){
    printf("Hello thread.\n");
    pthread_exit(NULL);
}

int main(int argc, char* argv[]){
    pthread_t t;
    int rc;
    rc = pthread_create(&t, NULL, threadfunc, NULL);
    printf("Create return code: %i\n", rc);
    if(!rc){
        pthread_join(t, NULL);
    }
    return 0;
}

编译为 crtbndc pgm(test) srcfile(myfile) srcmbr(test)

当使用 call test 调用时,我得到输出:

Create return code: 3029

这个错误代码是什么意思?

根据 IBM i documentation,似乎不支持 pthreads:

Thread creation (pthread_create()) fails with EBUSY or 3029

Because many parts of the operating system are not yet thread safe, not every job can start threads. The pthread_create() API fails with the EBUSY error when the process is not allowed to create threads. See Running threaded programs for information about how to start a job that can create threads.

它建议了一些 alternatives

错误 return 代码可以通过查看相关消息 ID 的消息描述来最容易地解释。使用前缀 'CPE' 和字符 return 代码“3029”。所以对于这个,请看这个命令:

DSPMSGD CPE3029

在这种情况下,一级文本是 "Resource busy." 这可能指的是显示 file/device 已经在使用中并分配给作业的主线程(假设 CALL 是在互动工作中制作)。

在程序中,您可以查看 ILE C/C++ 程序员指南中的 Checking the Errno Value 主题。库QSYSINC中的H源文件中的ERRNO成员也要审核。

此外,知识中心中有 Errno Values for UNIX-Type Functions 个 table。