GetCurrentThreadId()

This is a discussion on GetCurrentThreadId() within the C++ Programming forums, part of the General Programming Boards category; Hi, GetCurrentThreadId() works on a WIN32 machine. Can anyone tell me if GetCurrentThreadId() works on a linux machine. If it ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    10

    GetCurrentThreadId()

    Hi,

    GetCurrentThreadId() works on a WIN32 machine. Can anyone tell me if GetCurrentThreadId() works on a linux machine. If it does work also let me know the header file to include.

    Thanks,
    Chandana.

  2. #2
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Nope; that is a MS-specific call. Google for POSIX and threading, specifically pthreads to see how Linux/UNIX does it. This is why I am happy that the new C++ std is incorporating thread behavior...too many years of writing cross-platform thread code I guess but having a single standard will be great, not just from an API standpoint but also the angle of expected language behavior. Just look at the difference between setting/modifying thread priorities between platforms as it is now...ugh...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,579
    the equivalent on a platform that has pthreads as its native threading system would be pthread_self.

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    I need to dig through my info on the new C++ standard methods to see if pthread_self still works (doubt it is that *exactly* since this is supposed to be platform-neutral) but it might be something generalized like gettid() or something.

    Caveat: I just got home from a week-long music fest and brain not totally engaged yet....
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    10
    Thanks to all.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21