Find the answer to your Linux question:
Results 1 to 4 of 4
I am using dapper 6 ubuntu. I was coding a multithreaded application. and i found that while my system recognizes some of the pthread API functions , it cannot identify ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Posts
    2

    pthread problem


    I am using dapper 6 ubuntu. I was coding a multithreaded application. and i found that while my system recognizes some of the pthread API functions , it cannot identify functions like pthread_getthreadid_np(). can anyone tell me what the problem is ....
    otherwise also can someone suggest me as how to identify the posix threads without using the identity functions of the API.

    thanks in advance

  2. #2
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    I think pthread_t should be enough.

    When you create a new thread you may pass a pthread_t pointer as argument. This argument is used by other functions like pthread_cancel to identify the thread.

    Is this useful?

    Best regards!

  3. #3
    Just Joined!
    Join Date
    May 2006
    Posts
    2

    no ..

    thanx for the prompt reply but i think u didnt get the problem. The compiler is able to identify pthread_create , pthread_exit, pthread_init ..... but it is not able to identify (or find the definition to be precise) the thread specific identity (_np functions) functions. so while compiling it just reports that the function has not been defined in the scope.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    That could be because of the pthread implementation in Linux. My recently updated Debian hasn't that definitions. Other os like Mac OS X (actually it is a BSD kernel...) implements that functions.

    The only way to identify a thread AFAIK is working with pthread_t, that is defined as an "opaque id." although it is defined as:

    typedef unsigned long int pthread_t;

    at pthreadtypes.h

    So I said before that pthread_t should be enough to send messages to a certain thread. And because it is opaque, you can not "get a number" for each thread.

    In fact the POSIX standard doesn't force a specific type (int, long, long long....) for the thread identification.

    More here: http://lists.freebsd.org/pipermail/f...ry/002819.html

    Best regards

Posting Permissions

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