Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Oct 2003 13:46:52 -0400 (EDT)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Jake Burkholder <jake@locore.ca>
Cc:        sparc64@freebsd.org
Subject:   Re: Review for libpthread support
Message-ID:  <Pine.GSO.4.10.10310051338550.68-100000@pcnet5.pcnet.com>
In-Reply-To: <200310051319.29901.jake@locore.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 5 Oct 2003, Jake Burkholder wrote:

> On Sunday 05 October 2003 12:21, Daniel Eischen wrote:
> > Hi guys,
> >
> > I have a patch for adding libpthread support for sparc64.  It's jake's
> > patch, with a few mods by myself.  I'd like for some folks to look it
> > over.  I haven't tested it; I need a couple of questions answered
> > first so I can fill in a missing piece.
> >
> >   o Can someone look at the end of __thr_getcontext (line 524 of
> >     the patch)?  I need to test %i2 for NULL and branch to 1 if true.
> >
> > 	+/*	bz	%i2, 1f */
> > 	+	stx	%i1, [%i2]
> > 	+1:	ldx	[%sp], %i1			/* restore %i1 */
> > 	+	ldx	[%sp + 8], %i2			/* restore %i2 */
> 
> brz.  Beware of delay slots, the instruction after a branch is executed before 
> the branch is taken.

OK.

> 
> Use the locals as temporaries instead of using the stack, eg

What if a thread gets interrupted while using locals?  _thr_setcontext()
is suppose to be able to resume a thread that was interrupted anywhere.
What if some library function used locals, thread T1 had a page
fault, and it's context was exported back to libpthread?  The
library may run other threads before resuming T1 again.

> 
> 	mov	%i0, %l0
> 	mov	%i1, %l1
> 	mov	%i2, %l2
> ...
> 	ldx	[%l0 + MC_TPC], %l4
> 	ldx	[%l0 + MC_TNPC], %l3
> 	brz	%l1, 1f
> 	 nop
> 	stx	%l2, [%l1]
> 1:	jmpl	%l3, %g0
> 	 return %l4
> 
> Jake
> 
> >
> >     What's the magic instruction I should use?
> >
> >   o Can someone look over the context saving/restoring in general?
> >     I have a feeling there should be more to __thr_getcontext than
> >     there is.
> >
> > The patch is at:
> >
> >   http://people.freebsd.org/~deischen/kse/libpthread_sparc64.diffs
> >
> > I'm not subscribed to this list, so please keep me on the CC.
> >
> > Thanks,
> 

-- 
Dan Eischen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10310051338550.68-100000>