NAME

get_kjb_pthread_number - Get this thread's identity index

SYNOPSIS

#include "l_mt/l_mt_pthread.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


int get_kjb_pthread_number(void);

DESCRIPTION

Sometimes a thread wants to know, "who am I?" In other words, what is the identity info of this thread? The native Pthreads way to answer to this question is available via our wrapped function get_kjb_pthread_self(). Unfortunately it only returns a kjb_pthread_t object, which is disappointing, because it cannot be printed, and it can only be compared to that of other threads with kjb_pthread_equal(). You cannot order these structures in a portable way. As an alternative, you can use this function to get an integer that identifies this thread. The original, primal thread that started the program always and only gets value 0. All threads created with kjb_pthread_create() get a positive integer identity. Unless the counter is reset, the threads will all get identity integers increasing by one in the order that they were created (with the caveat below). Use reset_kjb_pthread_counter() to re-start the identity values at one.

RETURNS

Identity integer of the calling thread.

CAVEAT

I've observed some funny situations with threads that suggest that thread identity sometimes is permuted slightly from thread creation order -- I am not sure what to make of that. The condition is intermittent and hard to replicate, and lately it has gone away entirely, but who knows if it could return. So I would recommend threads use this function rather than receive a creation order number as (or inside) its startup argument. LOCK STATUS: no, this does not block

RELATED

get_kjb_pthread_self, reset_kjb_pthread_counter

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Andrew Predoehl

DOCUMENTER

Andrew Predoehl

SEE ALSO

kjb_pthread_create , kjb_pthread_mutex_lock , kjb_pthread_mutex_trylock , kjb_pthread_mutex_unlock , kjb_pthread_equal , get_kjb_pthread_self , kjb_pthread_exit , kjb_pthread_join , kjb_pthread_cancel , kjb_pthread_mutex_init , kjb_pthread_mutex_destroy , kjb_multithread_wrapper_serialization_lock , kjb_multithread_wrapper_serialization_unlock , kjb_pthread_key_create , kjb_pthread_key_delete , kjb_pthread_setspecific , kjb_pthread_getspecific , kjb_pthread_once , kjb_pthread_read_prng_seeds , kjb_pthread_attr_init , kjb_pthread_attr_destroy , kjb_pthread_attr_setdetachstate , kjb_pthread_attr_getdetachstate , reset_kjb_pthread_counter