diff options
author | jake <jake@FreeBSD.org> | 2003-04-03 03:34:50 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2003-04-03 03:34:50 +0000 |
commit | 5b2b2811a19544037b626ef44e598691b3b2f525 (patch) | |
tree | d95f2bb910f0eebc71243aa5c4f13994c66da5ec /lib/libthr/arch/i386 | |
parent | 12c39a9461b4db1d8608dca0cb0cfc47ff8b234e (diff) | |
download | FreeBSD-src-5b2b2811a19544037b626ef44e598691b3b2f525.zip FreeBSD-src-5b2b2811a19544037b626ef44e598691b3b2f525.tar.gz |
- Pass a ucontext_t to _set_curthread. If non-NULL the new thread is set
as curthread in the new context, so that it will be set automatically when
the thread is switched to. This fixes a race where we'd run for a little
while with curthread unset in _thread_start.
Reviewed by: jeff
Diffstat (limited to 'lib/libthr/arch/i386')
-rw-r--r-- | lib/libthr/arch/i386/i386/_setcurthread.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libthr/arch/i386/i386/_setcurthread.c b/lib/libthr/arch/i386/i386/_setcurthread.c index 7eac3ba..29cd646 100644 --- a/lib/libthr/arch/i386/i386/_setcurthread.c +++ b/lib/libthr/arch/i386/i386/_setcurthread.c @@ -27,6 +27,7 @@ */ #include <sys/types.h> +#include <sys/ucontext.h> #include <stdio.h> @@ -66,7 +67,7 @@ _retire_thread(void *entry) } void * -_set_curthread(void *thr) +_set_curthread(ucontext_t *uc, void *thr) { union descriptor desc; void **ldt_entry; @@ -116,7 +117,10 @@ _set_curthread(void *thr) /* * Set up our gs with the index into the ldt for this entry. */ - _set_gs(LSEL(ldt_index, SEL_UPL)); + if (uc != NULL) + uc->uc_mcontext.mc_gs = LSEL(ldt_index, SEL_UPL); + else + _set_gs(LSEL(ldt_index, SEL_UPL)); return (ldt_entry); } |