summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-10-20 21:08:47 +0000
committerjulian <julian@FreeBSD.org>2002-10-20 21:08:47 +0000
commit34c14a0b1d5959e34ef6a0898718a1195873c8d9 (patch)
treea1d7903aa308246f2d43b3f073e086fea0c3bdf7
parent514e18872c6b9349815dfaa980e7bab313df799d (diff)
downloadFreeBSD-src-34c14a0b1d5959e34ef6a0898718a1195873c8d9.zip
FreeBSD-src-34c14a0b1d5959e34ef6a0898718a1195873c8d9.tar.gz
Add an actual implementation of kse_wakeup()
Submitted by: Davidxu
-rw-r--r--sys/kern/kern_proc.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 66b3c79..e38a6fb 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -329,8 +329,48 @@ kse_release(struct thread *td, struct kse_release_args *uap)
int
kse_wakeup(struct thread *td, struct kse_wakeup_args *uap)
{
+ struct proc *p;
+ struct kse *ke, *ke2;
+ struct ksegrp *kg;
- return(ENOSYS);
+ p = td->td_proc;
+ /* KSE-enabled processes only, please. */
+ if (!(p->p_flag & P_KSES))
+ return EINVAL;
+ if (td->td_standin == NULL)
+ td->td_standin = thread_alloc();
+ ke = NULL;
+ mtx_lock_spin(&sched_lock);
+ if (uap->mbx) {
+ FOREACH_KSEGRP_IN_PROC(p, kg) {
+ FOREACH_KSE_IN_GROUP(kg, ke2) {
+ if (ke2->ke_mailbox != uap->mbx)
+ continue;
+ if (ke2->ke_flags & KEF_IDLEKSE) {
+ ke = ke2;
+ goto found;
+ } else {
+ mtx_unlock_spin(&sched_lock);
+ td->td_retval[0] = 0;
+ td->td_retval[1] = 0;
+ return 0;
+ }
+ }
+ }
+ } else {
+ kg = td->td_ksegrp;
+ ke = TAILQ_FIRST(&kg->kg_iq);
+ }
+ if (ke == NULL) {
+ mtx_unlock_spin(&sched_lock);
+ return ESRCH;
+ }
+found:
+ thread_schedule_upcall(td, ke);
+ mtx_unlock_spin(&sched_lock);
+ td->td_retval[0] = 0;
+ td->td_retval[1] = 0;
+ return 0;
}
/*
OpenPOWER on IntegriCloud