void initialize_thread_priority(omrthread_t thread) { int policy, priority, i; struct sched_param sched_param; /* set the default value */ thread->priority = J9THREAD_PRIORITY_NORMAL; /* are we using priorities at all? */ if (priority_map[J9THREAD_PRIORITY_MIN] == priority_map[J9THREAD_PRIORITY_MAX]) { return; } if (pthread_getschedparam(thread->handle, &policy, &sched_param)) { /* the call failed */ return; } #if defined(J9_PRIORITY_MAP) if (policy != J9_DEFAULT_SCHED) { /* incompatible policy for our priority mapping */ return; } #endif /* * Similar story for AIX as IRIX, except AIX uses 1 instead of 0. * * Each thread in AIX starts out as a floating priority SCHED_OTHER thread. * Once we assign a pthread priority it becomes a fixed priority thread with * policy SCHED_OTHER, SCHED_FIFO, SCHED_RR or other. */ if (sched_param.sched_priority == 1) { set_pthread_priority(thread->handle, thread->priority); return; } #ifndef J9OS_I5 /* explicitly disabled by iSeries team */ /* on some platforms (i.e. Solaris) we get out of range values (e.g. 0) for threads with no explicitly set priority */ if (sched_param.sched_priority < sched_get_priority_min(policy) || sched_param.sched_priority > sched_get_priority_max(policy)) { return; } #endif thread->priority = omrthread_map_native_priority(sched_param.sched_priority); }
static void set_realtime(int type, int priority){ //bound_thread_to_cpu(0); set_pthread_priority(pthread_self(),type,priority,"Unable to set %s/%d for %d (\"%s\"). (%s)", "a gc thread"); }