Subject: Re: Return value of cpu_switchto(9)
To: Martin Husemann <martin@duskware.de>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 05/20/2007 22:36:20
On Sun, May 20, 2007 at 11:14:49PM +0200, Martin Husemann wrote:
> On Sun, May 20, 2007 at 01:58:23PM -0700, Matt Thomas wrote:
> > switchto(NULL, tmp); /* old is deleted *.
> > switchto(tmp, x);
> >
> > if old was returned, it would be to a deleted lwp and that can't be
> > right.
>
> I don't understand. In the switchto(NULL, tmp) case - should it return
> NULL, or the lwp it is switching away from?
>
> My reading of the man page says the latter, but code for the ports
> I checked does the former.
The latter: switchto(NULL, tmp) should return NULL. A null value is passed
in when an LWP is exiting. It's used as a hint to avoid some locking, and to
avoid saving any state (there's no point doing doing either).
Andrew