Erzeugen meines Threads:
Code: Alles auswählen
pthread_t *thread;
pthread_attr_t attr;
int ret;
thread=(pthread_t*)malloc(sizeof(pthread_t));
if (!thread) return NULL;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
ret=pthread_create(thread,&attr,start_routine,arg);
if (ret==0) return thread;
Code: Alles auswählen
sched_param param;
int policy,range;
if (pthread_getschedparam((pthread_t)handle, &policy, ¶m)!=0) return false;
range=(sched_get_priority_max(policy)-sched_get_priority_min(policy))-2; // get the range but never use the absolute max/min values
param.sched_priority=(range/5)*(prio+2)+1;
return (pthread_setschedparam((pthread_t)handle, policy, ¶m)==0);