pthread_self

Submitted by jelari
on June 18, 2008 - 7:50am

Hi i have create a POSIX thread and trying to pring thread id through pthread_self(), when i print that with %d or %ld, i am getting the negative value?.. what is the workaround for this issue?. My linux version is
2.6.22-14-server.

Pthread ids are long

on
June 18, 2008 - 1:23pm

Pthread ids are long unsigned int, while %d is for signed ints. Try using %u instead or %lu.

pthread_t is an opaque type.

Paul Brook (not verified)
on
June 18, 2008 - 7:13pm

pthread_t is an opaque type. Expect anything that tries to manipulate it directly (e.g. by passing it as an argument to printf) to break.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.