This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The problem with __pthread_manager_adjust_prio


On Fri, Mar 22, 2002 at 02:04:49AM -0800, Ulrich Drepper wrote:
> On Thu, 2002-03-21 at 00:24, H . J . Lu wrote:
>  
> > A new patch with spinlock.
> 
> This patch isn't right either.  There is no guarantee that the new
> thread gets scheduled before the manager creates another thread.
> 
> Looking at the code I don't understand why the priority the manager
> selects for the thread creation isn't stored in memory local to the
> newly created thread.  This would fix the problem.  If you also think
> that I don't miss anything you might want to send such a patch.
> 

The problem is the new thread will inherit the scheduler of the manager
thread which may be changed by other threads. The new thread has to
know if the manager's scheduler has been changed to decide if it should
call __sched_setscheduler (SCHED_OTHER). There are 2 race conditons for
accessing manager_thread->p_priority between 2 threads:

1. One thread calls pthread_setschedparam which calls
__pthread_manager_adjust_prio and the other is created by
pthread_create which leads to pthread_start_thread.
2. Both threads call pthread_setschedparam which calls
__pthread_manager_adjust_prio.

The new thread can call __sched_setscheduler (SCHED_OTHER) without
checking manager_thread->p_priority. It will solve #1. But #2 still
remains.


H.J.

H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]