https://bugzilla.novell.com/show_bug.cgi?id=250594 Summary: pthread_attr_setscheduler() does not have the desired effect Product: openSUSE 10.2 Version: Final Platform: i686 OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: bart.vanassche@gmail.com QAContact: qa@suse.de When creating a thread with pthread_create() thread attributes can be passed as the second argument of pthread_create(). This doesn't seem to have any effect however when using NPTL (this code did work with linuxthreads). Root privileges are necessary for this test since SCHED_FIFO / SCHED_RR threads can only be created by a process with root privileges. # id uid=0(root) gid=0(root) groups=0(root) # ./pthread-create main: creating a thread with policy 1 and priority 99 Thread 3086445472: scheduling policy 0 and priority 0 # cat pthread-create.cpp #include <cassert> #include <iostream> #if ! defined NDEBUG #define VERIFY(e) assert(e) #else #define VERIFY(e) (e) #endif static void* thread_func(void*) { int policy; sched_param param; VERIFY(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); std::cout << "Thread " << pthread_self() << ": scheduling policy " << policy << " and priority " << param.sched_priority << std::endl; return 0; } int main(int, char**) { pthread_t the_thread; pthread_attr_t attr; pthread_attr_init(&attr); VERIFY(pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 1) == 0); const int policy = SCHED_FIFO; VERIFY(pthread_attr_setschedpolicy(&attr, policy) == 0); struct sched_param SchedParam; SchedParam.sched_priority = 99; VERIFY(pthread_attr_setschedparam(&attr, &SchedParam) == 0); std::cout << "main: creating a thread with policy " << policy << " and priority " << SchedParam.sched_priority << std::endl; VERIFY(pthread_create(&the_thread, &attr, &thread_func, 0) == 0); pthread_attr_destroy(&attr); pthread_join(the_thread, 0); return 0; } // Local variables: // compile-command: "g++ -g -Wall -Wextra -Werror -O3 pthread-create.cpp -o pthread-create -lpthread" // End: -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.