summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-10-09 02:33:36 +0000
committerjulian <julian@FreeBSD.org>2002-10-09 02:33:36 +0000
commit6b6ba96b60d9de6b157e3a804963854cde6eec5b (patch)
tree93491b956e59fcfe0f873643838ff7944a49abe7 /sys/kern/kern_proc.c
parent03d461282bdbbe2384e949089d84ae6a3821e7ca (diff)
downloadFreeBSD-src-6b6ba96b60d9de6b157e3a804963854cde6eec5b.zip
FreeBSD-src-6b6ba96b60d9de6b157e3a804963854cde6eec5b.tar.gz
Round out the facilty for a 'bound' thread to loan out its KSE
in specific situations. The owner thread must be blocked, and the borrower can not proceed back to user space with the borrowed KSE. The borrower will return the KSE on the next context switch where teh owner wants it back. This removes a lot of possible race conditions and deadlocks. It is consceivable that the borrower should inherit the priority of the owner too. that's another discussion and would be simple to do. Also, as part of this, the "preallocatd spare thread" is attached to the thread doing a syscall rather than the KSE. This removes the need to lock the scheduler when we want to access it, as it's now "at hand". DDB now shows a lot mor info for threaded proceses though it may need some optimisation to squeeze it all back into 80 chars again. (possible JKH project) Upcalls are now "bound" threads, but "KSE Lending" now means that other completing syscalls can be completed using that KSE before the upcall finally makes it back to the UTS. (getting threads OUT OF THE KERNEL is one of the highest priorities in the KSE system.) The upcall when it happens will present all the completed syscalls to the KSE for selection.
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r--sys/kern/kern_proc.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index bd613c45..82138a5 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -241,9 +241,7 @@ kse_link(struct kse *ke, struct ksegrp *kg)
TAILQ_INSERT_HEAD(&kg->kg_kseq, ke, ke_kglist);
kg->kg_kses++;
- ke->ke_state = KES_IDLE;
- TAILQ_INSERT_HEAD(&kg->kg_iq, ke, ke_kgrlist);
- kg->kg_idle_kses++;
+ ke->ke_state = KES_UNQUEUED;
ke->ke_proc = p;
ke->ke_ksegrp = kg;
ke->ke_thread = NULL;
@@ -310,24 +308,17 @@ kse_exit(struct thread *td, struct kse_exit_args *uap)
int
kse_release(struct thread *td, struct kse_release_args *uap)
{
- struct thread *td2;
+ struct proc *p;
+ p = td->td_proc;
/* KSE-enabled processes only, please. */
- if ((td->td_proc->p_flag & P_KSES) == 0)
- return (EINVAL);
-
- /* Don't discard the last thread. */
- td2 = FIRST_THREAD_IN_PROC(td->td_proc);
- KASSERT(td2 != NULL, ("kse_release: no threads in our proc"));
- if (TAILQ_NEXT(td, td_plist) == NULL)
- return (EINVAL);
-
- /* Abandon thread. */
- PROC_LOCK(td->td_proc);
- mtx_lock_spin(&sched_lock);
- thread_exit();
- /* NOTREACHED */
- return (0);
+ if (p->p_flag & P_KSES) {
+ PROC_LOCK(p);
+ mtx_lock_spin(&sched_lock);
+ thread_exit();
+ /* NOTREACHED */
+ }
+ return (EINVAL);
}
/* struct kse_wakeup_args {
@@ -423,6 +414,10 @@ kse_create(struct thread *td, struct kse_create_args *uap)
if (SIGPENDING(p))
newke->ke_flags |= KEF_ASTPENDING;
PROC_UNLOCK(p);
+ /* For the first call this may not have been set */
+ if (td->td_standin == NULL) {
+ td->td_standin = thread_alloc();
+ }
mtx_lock_spin(&sched_lock);
if (newkg)
ksegrp_link(newkg, p);
OpenPOWER on IntegriCloud