Re: Negative numbers for thread ID - why ?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Re: Negative numbers for thread ID - why ?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: Negative numbers for thread ID - why ?  
Lew Pitcher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-17-07 06:17 PM


markryde@gmail.com wrote:
> Hello,
>
> I am running FC6 machine (i386 based).
> I am trying the follwing:
>
>  create a thread with pthread_create().
>  in the thread function, I have:
>  printf("tid in thread_func=%d\n",(int)pthread_self());
>
>  I get negative number for the thread id, for example:
>
>  tid in thread2_func=-1218974832
>
>  Why is it so ?

Why? Because you made it so.
Remember, the "%d" printf format string tells printf to interpret the
incoming value as a *signed* integer. The data you got back from
pthread_self(), when cast to an integer value and interpreted as a
signed integer, had a value of -1218974832. Had you told printf() to
print it as "%u", you would have seen a different printed value because
you would have told printf() to interpret the number as an unsigned
integer.

>  I saw in some places usage of this method (pthread_self()),but
> it returned non negative numbers.

This usage will print non-negative values for pthread_self() values
that are smaller than INT_MAX + 1






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:21 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register