what is pthread_attr_t ?

Hello Everyone,

I’m new to QNX API’s and I really need some help. I dont understand the use of “pthread_attr_t”. I saw a lot of sample programs for instance:

int main(){

pthread_attr_t attr;

pthread_attr_init(&attr);

pthread_create(NULL, &attr, &somefunction, NULL);

sleep(60);

return;

}

I undrstand that the programmer wants to initialize the attribute of that particular thread but by simply writing the following:

pthread_attr_t attr;

what attr is initialized to? and what is pthread_attr_t really ?

Thanks
bob

You can use the pthread_attr_t to change attributes on your thread, such as priority, scheduling type (fifo,RR,sporadic) etc
look at the pthread_atttr * functions in the helpviewer

Hi phearbear,

the code that iw rote above doesn’t show that the “attr” is et to some value. Could you give me an example on how to initialize the attr?

Thanks
bob

pthread_attr_t is typedef’d in /usr/include/pthread.h as __PTHREAD_ATTR_T,
__PTHREAD_ATTR_T is defined in /usr/include/sys/target_nto.h, which is a
“struct _thread_attr”.

pthread_attr_init(&attr);

This initialized the “attr” structure.

Ok…but “attr” is initialized with what values?

Thanks
bob

tamayo - it is setup to system defaults. If you read each of the attribute manipulation functions it will tell you the defaults. From the point-of-view of the user, the structure is opaque - you don’t know what is inside of it.