diff options
| author | Julian Elischer <julian@FreeBSD.org> | 2002-10-24 23:09:48 +0000 | 
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 2002-10-24 23:09:48 +0000 | 
| commit | 1434d3fe6fbdf2e79767e8a4eb7ea58247327395 (patch) | |
| tree | 62423a3307545934139e299f4e19177031d11875 /sys/kern/kern_thread.c | |
| parent | d28e8b3a0d063a169a7f899acef3c6df3bf7aca2 (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_thread.c')
| -rw-r--r-- | sys/kern/kern_thread.c | 47 | 
1 files changed, 47 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 02a62f6ee587..d47f32e908e2 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1158,6 +1158,53 @@ return (NULL);  }  /* + * setup done on the thread when it enters the kernel. + * XXXKSE Presently only for syscalls but eventually all kernel entries. + */ +void +thread_user_enter(struct proc *p, struct thread *td) +{ +	struct kse *ke; + +	/* +	 * First check that we shouldn't just abort. +	 * But check if we are the single thread first! +	 * XXX p_singlethread not locked, but should be safe. +	 */ +	if ((p->p_flag & P_WEXIT) && (p->p_singlethread != td)) { +		PROC_LOCK(p); +		mtx_lock_spin(&sched_lock); +		thread_exit(); +		/* NOTREACHED */ +	} + +	/* +	 * If we are doing a syscall in a KSE environment, +	 * note where our mailbox is. There is always the +	 * possibility that we could do this lazily (in sleep()), +	 * but for now do it every time. +	 */ +	if ((ke = td->td_kse->ke_mailbox)) { +#if 0 +		td->td_mailbox = (void *)fuword((caddr_t)ke->ke_mailbox +		    + offsetof(struct kse_mailbox, km_curthread)); +#else /* if user pointer arithmetic is ok in the kernel */ +		td->td_mailbox = +		    (void *)fuword( (void *)&ke->ke_mailbox->km_curthread); +#endif +		if ((td->td_mailbox == NULL) || +		    (td->td_mailbox == (void *)-1)) { +			td->td_mailbox = NULL;	/* single thread it.. */ +			td->td_flags &= ~TDF_UNBOUND; +		} else { +			if (td->td_standin == NULL) +				td->td_standin = thread_alloc(); +			td->td_flags |= TDF_UNBOUND; +		} +	} +} + +/*   * The extra work we go through if we are a threaded process when we   * return to userland.   *  | 
