cmultithreadingpthreadsibm-midrange

pthread error code 3029 on the as400/IBM I?


I have the following C source:

#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;
}

Compiled with crtbndc pgm(test) srcfile(myfile) srcmbr(test)

When called with call test, I get the output:

Create return code: 3029

What does this error code mean?


Solution

  • According to IBM i documentation, pthreads doesn't seem to be supported:

    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.

    And it suggests a few alternatives.