diff options
author | marcel <marcel@FreeBSD.org> | 2004-07-02 00:40:07 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-07-02 00:40:07 +0000 |
commit | 622fe058c99b4a6cac2805c8352c92b4330882f9 (patch) | |
tree | 9c8400ddc4d640b6eb03f81ba5983718f183b0e0 /sys/kern/kern_thr.c | |
parent | e84fdd61ba2c15de745151bb597597aed2b690ed (diff) | |
download | FreeBSD-src-622fe058c99b4a6cac2805c8352c92b4330882f9.zip FreeBSD-src-622fe058c99b4a6cac2805c8352c92b4330882f9.tar.gz |
Change the thread ID (thr_id_t) used for 1:1 threading from being a
pointer to the corresponding struct thread to the thread ID (lwpid_t)
assigned to that thread. The primary reason for this change is that
libthr now internally uses the same ID as the debugger and the kernel
when referencing to a kernel thread. This allows us to implement the
support for debugging without additional translations and/or mappings.
To preserve the ABI, the 1:1 threading syscalls, including the umtx
locking API have not been changed to work on a lwpid_t. Instead the
1:1 threading syscalls operate on long and the umtx locking API has
not been changed except for the contested bit. Previously this was
the least significant bit. Now it's the most significant bit. Since
the contested bit should not be tested by userland, this change is
not expected to be visible. Just to be sure, UMTX_CONTESTED has been
removed from <sys/umtx.h>.
Reviewed by: mtm@
ABI preservation tested on: i386, ia64
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r-- | sys/kern/kern_thr.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 50fed6e..d1b5d3f 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -118,11 +118,12 @@ thr_exit1(void) */ int thr_create(struct thread *td, struct thr_create_args *uap) - /* ucontext_t *ctx, thr_id_t *id, int flags */ + /* ucontext_t *ctx, long *id, int flags */ { struct kse *ke0; struct thread *td0; ucontext_t ctx; + long id; int error; if ((error = copyin(uap->ctx, &ctx, sizeof(ctx)))) @@ -135,7 +136,8 @@ thr_create(struct thread *td, struct thr_create_args *uap) * Try the copyout as soon as we allocate the td so we don't have to * tear things down in a failure case below. */ - if ((error = copyout(&td0, uap->id, sizeof(thr_id_t)))) { + id = td0->td_tid; + if ((error = copyout(&id, uap->id, sizeof(long)))) { thread_free(td0); return (error); } @@ -163,7 +165,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) kse_free(ke0); thread_free(td0); goto out; - } + } /* Link the thread and kse into the ksegrp and make it runnable. */ mtx_lock_spin(&sched_lock); @@ -190,11 +192,13 @@ out: int thr_self(struct thread *td, struct thr_self_args *uap) - /* thr_id_t *id */ + /* long *id */ { + long id; int error; - if ((error = copyout(&td, uap->id, sizeof(thr_id_t)))) + id = td->td_tid; + if ((error = copyout(&id, uap->id, sizeof(long)))) return (error); return (0); @@ -223,7 +227,7 @@ thr_exit(struct thread *td, struct thr_exit_args *uap) int thr_kill(struct thread *td, struct thr_kill_args *uap) - /* thr_id_t id, int sig */ + /* long id, int sig */ { struct thread *ttd; struct proc *p; @@ -233,7 +237,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) error = 0; PROC_LOCK(p); FOREACH_THREAD_IN_PROC(p, ttd) { - if (ttd == uap->id) + if (ttd->td_tid == uap->id) break; } if (ttd == NULL) { @@ -291,14 +295,13 @@ thr_suspend(struct thread *td, struct thr_suspend_args *uap) int thr_wake(struct thread *td, struct thr_wake_args *uap) - /* thr_id_t id */ + /* long id */ { - struct thread *tdsleeper, *ttd; + struct thread *ttd; - tdsleeper = ((struct thread *)uap->id); PROC_LOCK(td->td_proc); FOREACH_THREAD_IN_PROC(td->td_proc, ttd) { - if (ttd == tdsleeper) + if (ttd->td_tid == uap->id) break; } if (ttd == NULL) { @@ -306,9 +309,9 @@ thr_wake(struct thread *td, struct thr_wake_args *uap) return (ESRCH); } mtx_lock_spin(&sched_lock); - tdsleeper->td_flags |= TDF_THRWAKEUP; + ttd->td_flags |= TDF_THRWAKEUP; mtx_unlock_spin(&sched_lock); - wakeup_one((void *)tdsleeper); + wakeup_one((void *)ttd); PROC_UNLOCK(td->td_proc); return (0); } |