Differently cope with the possibility of the thread attributes being
NULL during thread_create_and_bind. This new solution initializes it
internally, thus avoiding a potential non-initialized used of variable
p, containing thread priority.
wp.vres = vres;
wp.stopper = &stopper;
- if (attr) {
- pthread_attr_getschedparam(attr, ¶m);
- p = param.sched_priority;
- printf("priority = %d\n", p);
- }
+ if (!attr)
+ pthread_attr_init(attr);
+
+ pthread_attr_getschedparam(attr, ¶m);
+ p = param.sched_priority;
+ printf("priority = %d\n", p);
if (p == 0) {
param.sched_priority = 1;
pthread_attr_setschedparam(attr, ¶m);