CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2002
    Location
    USA
    Posts
    5

    Question pthread_create Function

    I trying to create multi thread programming in C.

    I am getting ENOSYS error from pthread_create function. I would appreciate if someone can assit me. I am calling function thread_loop twice. But it is executing only once. Gettint error from pthread_create function. Thanks.


    #include <pthread.h>
    #include <errno.h>


    void* thread_loop(void* data)
    {

    int i = 0;
    long j = 0;

    printf("Inside the function \n");

    for (i = 0 ; i<5; i++)
    {
    for (j=0; j<900 ; j++);
    printf("I value %d \n", i);
    }

    }

    void main(int argc, char *argv[] )
    {


    int i = 1;

    pthread_t thread1 ;

    int ret ;


    ret = pthread_create(&thread1, NULL, thread_loop, (void*) &i) ;


    switch (ret)
    {

    case 0 : printf("pthread_create function Success \n"); break ;

    case EAGAIN : printf("Error : No more processes \n"); break ;

    case ENOSYS : printf("Error : Function not implemented \n"); break ;

    case EINVAL : printf("Error : Invalid Argument \n"); break ;

    case EPERM : printf("Error : Not super-user \n"); break ;

    default : printf("Other error from pthread_create \n"); break ;

    }

    printf("End Of Main %d \n ", ret);

    thread_loop(&i);

    }

  2. #2
    Join Date
    Sep 1999
    Posts
    102
    Aside from not linking with pthread library - but i don't know if you should get an error while compiling or linking- (might be that you dont - because of #define in h files...), any way, are you sure you get only one instrance of the function?
    Did you go thorugh the output to see you dont have duplicates?
    You could very easily mistake it - since both would be running at the same time...
    Take a good look at your print out - and look for doubles...
    If you have two of the same lines (not neseceraly at the same place) - it means all is working well.

  3. #3
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245
    What OS are you using?

  4. #4
    Join Date
    Feb 2002
    Location
    USA
    Posts
    5
    I am using unix OS.

    I am pretty sure it is not even entering the function.

  5. #5
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245
    There are a variety of unix platforms as well as different unix compilers. The error message suggests that the function is not implemented. I would consult the compiler manual (or man pages) as well as the OS documentation to see what it can support.

    - Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured