Subject: Re: SA/libpthread and page faults
To: Christian Limpach <chris@pin.lu>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: tech-kern
Date: 09/03/2003 18:26:32
Christian Limpach <chris@pin.lu> writes:

> - A upcall_switch can lose the thread it was going to switch to:
> 	movl	$PT_STATE_RECYCLABLE, PT_STATE(%eax)
> 	movl	%esi, PT_SWITCHTOUC(%eax)
> 	movl	%ecx, PT_SWITCHTO(%eax)
> If the upcall_switch is interrupted after setting the recyclable state 
> and before setting switchto/switchtouc, the interrupting upcall will not 
> continue the upcall_switch since it will recycle it.  This is solved by 
> setting the state last.

Relying on order is fragile, as you've noticed. I'd prefer to fix this
in pthread__resolve_locks() by changing the retire condition for
upcalls on a continuation chain to having a value set in pt_switchto,
as is done for application threads. This will permit us to remove the
store to PT_STATE entirely, and have one fewer order dependancy.

        - Nathan