pthread_create under linux

From: Andy Alex (andy_alex_at_gmx.net)
Date: 03/02/04

  • Next message: Kasper Dupont: "Re: pthread_create under linux"
    Date: 2 Mar 2004 04:53:32 -0800
    
    

    Hello

    Following code:
    -----------------------
    #include <stdio.h>
    #include <pthread.h>
    #include <unistd.h>

    void* thread_func(void* param) {
     printf("inside thread_func with arg=0%x\n",param);
     return 0;
    }

    int main() {
     pthread_t thread;
     printf("before pthread_create\n");
     int i=pthread_create(&thread,0,thread_func,0);
     printf("pthread_create returns %d, thread=0x%x\n",i,thread);
     sleep(5);
     return 0;
    }
    -----------------------
    g++ -static -pthread pthtest.cpp -o init
    -----------------------

    run fine under usual linux (debian 3.0 for example), but when I create
    one bootable floppy which consists of kernel 2.4.23 and this sample
    code compiled as `init` only, it fails. I can see only "before
    pthread_create" i.e. pthread_create hung into infinite loop and does
    return nothing.

    Why ???

    Should I perform any kind of initializaion of pthread library or
    something else to allow threading in this situation ?

    Andy Alex


  • Next message: Kasper Dupont: "Re: pthread_create under linux"

    Relevant Pages