On Thu, Sep 9, 2010 at 1:48 PM, Enlightenment SVN <no-re...@enlightenment.org> wrote: > Log: > Fix priority dropping > > Lowering priority was wrong. Some bugs: > > 1) You don't lower the priority by setting the scheduler policy to some > of the real-time ones (SCHED_RR or SCHER_FIFO). If you do so, you are > actually increasing the priority of the workers and your main thread > you be preempted and stalled until the workers complete their job. > Fortunately this will only happen if your programming is running as > root, as normal users (without CAP_SYS_NICE) are unable to set > priority to real-time values. > > 2) setpriority() and getpriority() are not part of pthread and you can't > use the id returned by pthread. Manpage explicitly says so on > pthread_self(3): > "The thread ID returned by pthread_self() is not the same thing as the > kernel thread ID returned by a call to gettid(2)." > > Since glibc does not have a gettid, here we are using > syscall(SYS_gettid) > > This patch was tested with the program below. Compile and run: > $ gcc p_hello2.c -o p_hello2 -lpthread > $ ./p_hello2 10 > > You'll see that the main thread remains with its priority and threads > created by the main thread change their own niceness.
This logic start to be really complex and sounds not really portable, I would advocate to move it in eina as eina_thread_priority_drop(void) and replace evas code also. -- Cedric BAIL ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel