Add an actual implementation of kse_thr_interrupt()
This commit is contained in:
parent
7a966f2ded
commit
34e80e027d
@ -270,8 +270,26 @@ proc_linkup(struct proc *p, struct ksegrp *kg,
|
||||
int
|
||||
kse_thr_interrupt(struct thread *td, struct kse_thr_interrupt_args *uap)
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td2;
|
||||
|
||||
return(ENOSYS);
|
||||
p = td->td_proc;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
FOREACH_THREAD_IN_PROC(p, td2) {
|
||||
if (td2->td_mailbox == uap->tmbx) {
|
||||
td2->td_flags |= TDF_INTERRUPT;
|
||||
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR)) {
|
||||
if (td2->td_flags & TDF_CVWAITQ)
|
||||
cv_abort(td2);
|
||||
else
|
||||
abortsleep(td2);
|
||||
}
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return(ESRCH);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1390,7 +1408,9 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
* it would be nice if this all happenned only on the first time
|
||||
* through. (the scan for extra work etc.)
|
||||
*/
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags &= ~TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
#if 0
|
||||
error = suword((caddr_t)ke->ke_mailbox +
|
||||
offsetof(struct kse_mailbox, km_curthread), 0);
|
||||
|
@ -157,10 +157,15 @@ msleep(ident, mtx, priority, wmesg, timo)
|
||||
if (p->p_flag & P_KSES) {
|
||||
/*
|
||||
* Just don't bother if we are exiting
|
||||
* and not the exiting thread.
|
||||
* and not the exiting thread or thread was marked as
|
||||
* interrupted.
|
||||
*/
|
||||
if ((p->p_flag & P_WEXIT) && catch && (p->p_singlethread != td))
|
||||
if (catch &&
|
||||
(((p->p_flag & P_WEXIT) && (p->p_singlethread != td)) ||
|
||||
(td->td_flags & TDF_INTERRUPT))) {
|
||||
td->td_flags &= ~TDF_INTERRUPT;
|
||||
return (EINTR);
|
||||
}
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((td->td_flags & (TDF_UNBOUND|TDF_INMSLEEP)) ==
|
||||
TDF_UNBOUND) {
|
||||
@ -277,6 +282,11 @@ msleep(ident, mtx, priority, wmesg, timo)
|
||||
p->p_stats->p_ru.ru_nivcsw++;
|
||||
mi_switch();
|
||||
td->td_flags &= ~TDF_TIMOFAIL;
|
||||
}
|
||||
if ((td->td_flags & TDF_INTERRUPT) && (priority & PCATCH) &&
|
||||
(rval == 0)) {
|
||||
td->td_flags &= ~TDF_INTERRUPT;
|
||||
rval = EINTR;
|
||||
}
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
|
@ -270,8 +270,26 @@ proc_linkup(struct proc *p, struct ksegrp *kg,
|
||||
int
|
||||
kse_thr_interrupt(struct thread *td, struct kse_thr_interrupt_args *uap)
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td2;
|
||||
|
||||
return(ENOSYS);
|
||||
p = td->td_proc;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
FOREACH_THREAD_IN_PROC(p, td2) {
|
||||
if (td2->td_mailbox == uap->tmbx) {
|
||||
td2->td_flags |= TDF_INTERRUPT;
|
||||
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR)) {
|
||||
if (td2->td_flags & TDF_CVWAITQ)
|
||||
cv_abort(td2);
|
||||
else
|
||||
abortsleep(td2);
|
||||
}
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return(ESRCH);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1390,7 +1408,9 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
* it would be nice if this all happenned only on the first time
|
||||
* through. (the scan for extra work etc.)
|
||||
*/
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags &= ~TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
#if 0
|
||||
error = suword((caddr_t)ke->ke_mailbox +
|
||||
offsetof(struct kse_mailbox, km_curthread), 0);
|
||||
|
@ -331,6 +331,7 @@ struct thread {
|
||||
#define TDF_ONSLEEPQ 0x000200 /* On the sleep queue. */
|
||||
#define TDF_INMSLEEP 0x000400 /* Don't recurse in msleep(). */
|
||||
#define TDF_TIMOFAIL 0x001000 /* Timeout from sleep after we were awake. */
|
||||
#define TDF_INTERRUPT 0x002000 /* Thread is marked as interrupted. */
|
||||
#define TDF_DEADLKTREAT 0x800000 /* Lock aquisition - deadlock treatment. */
|
||||
|
||||
#define TDI_SUSPENDED 0x01 /* On suspension queue. */
|
||||
|
Loading…
Reference in New Issue
Block a user