1. Migrate TDF_UPCALLING from td_flags to td_pflags.
2. Add a flag TDF_SA, it will be used to distinguish SA based thread from bound thread.
This commit is contained in:
parent
9bf69bf27a
commit
1d5a24bec6
@ -500,14 +500,8 @@ kse_release(struct thread *td, struct kse_release_args *uap)
|
||||
timespecadd(&ts, &timeout);
|
||||
TIMESPEC_TO_TIMEVAL(&tv, &timeout);
|
||||
}
|
||||
mtx_lock_spin(&sched_lock);
|
||||
/* Change OURSELF to become an upcall. */
|
||||
td->td_flags = TDF_UPCALLING;
|
||||
#if 0 /* XXX This shouldn't be necessary */
|
||||
if (p->p_sflag & PS_NEEDSIGCHK)
|
||||
td->td_flags |= TDF_ASTPENDING;
|
||||
#endif
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
PROC_LOCK(p);
|
||||
while ((td->td_upcall->ku_flags & KUF_DOUPCALL) == 0 &&
|
||||
(kg->kg_completed == NULL)) {
|
||||
@ -1379,7 +1373,7 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
|
||||
/* Let the new thread become owner of the upcall */
|
||||
ku->ku_owner = td2;
|
||||
td2->td_upcall = ku;
|
||||
td2->td_flags = TDF_UPCALLING;
|
||||
td2->td_pflags = TDP_UPCALLING;
|
||||
#if 0 /* XXX This shouldn't be necessary */
|
||||
if (td->td_proc->p_sflag & PS_NEEDSIGCHK)
|
||||
td2->td_flags |= TDF_ASTPENDING;
|
||||
@ -1432,9 +1426,7 @@ thread_signal_add(struct thread *td, int sig)
|
||||
void
|
||||
thread_signal_upcall(struct thread *td)
|
||||
{
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags |= TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1612,9 +1604,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
* strucuture, we can go to userland.
|
||||
* Turn ourself into an upcall thread.
|
||||
*/
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags |= TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
} else if (td->td_mailbox && (ku == NULL)) {
|
||||
error = thread_export_context(td);
|
||||
/* possibly upcall with error? */
|
||||
@ -1663,7 +1653,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
|
||||
if (td->td_flags & TDF_UPCALLING) {
|
||||
if (td->td_pflags & TDP_UPCALLING) {
|
||||
uts_crit = 0;
|
||||
kg->kg_nextupcall = ticks+kg->kg_upquantum;
|
||||
/*
|
||||
@ -1674,8 +1664,8 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
CTR3(KTR_PROC, "userret: upcall thread %p (pid %d, %s)",
|
||||
td, td->td_proc->p_pid, td->td_proc->p_comm);
|
||||
|
||||
td->td_pflags &= ~TDP_UPCALLING;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags &= ~TDF_UPCALLING;
|
||||
if (ku->ku_flags & KUF_DOUPCALL)
|
||||
ku->ku_flags &= ~KUF_DOUPCALL;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
@ -500,14 +500,8 @@ kse_release(struct thread *td, struct kse_release_args *uap)
|
||||
timespecadd(&ts, &timeout);
|
||||
TIMESPEC_TO_TIMEVAL(&tv, &timeout);
|
||||
}
|
||||
mtx_lock_spin(&sched_lock);
|
||||
/* Change OURSELF to become an upcall. */
|
||||
td->td_flags = TDF_UPCALLING;
|
||||
#if 0 /* XXX This shouldn't be necessary */
|
||||
if (p->p_sflag & PS_NEEDSIGCHK)
|
||||
td->td_flags |= TDF_ASTPENDING;
|
||||
#endif
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
PROC_LOCK(p);
|
||||
while ((td->td_upcall->ku_flags & KUF_DOUPCALL) == 0 &&
|
||||
(kg->kg_completed == NULL)) {
|
||||
@ -1379,7 +1373,7 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
|
||||
/* Let the new thread become owner of the upcall */
|
||||
ku->ku_owner = td2;
|
||||
td2->td_upcall = ku;
|
||||
td2->td_flags = TDF_UPCALLING;
|
||||
td2->td_pflags = TDP_UPCALLING;
|
||||
#if 0 /* XXX This shouldn't be necessary */
|
||||
if (td->td_proc->p_sflag & PS_NEEDSIGCHK)
|
||||
td2->td_flags |= TDF_ASTPENDING;
|
||||
@ -1432,9 +1426,7 @@ thread_signal_add(struct thread *td, int sig)
|
||||
void
|
||||
thread_signal_upcall(struct thread *td)
|
||||
{
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags |= TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1612,9 +1604,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
* strucuture, we can go to userland.
|
||||
* Turn ourself into an upcall thread.
|
||||
*/
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags |= TDF_UPCALLING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
td->td_pflags |= TDP_UPCALLING;
|
||||
} else if (td->td_mailbox && (ku == NULL)) {
|
||||
error = thread_export_context(td);
|
||||
/* possibly upcall with error? */
|
||||
@ -1663,7 +1653,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
|
||||
if (td->td_flags & TDF_UPCALLING) {
|
||||
if (td->td_pflags & TDP_UPCALLING) {
|
||||
uts_crit = 0;
|
||||
kg->kg_nextupcall = ticks+kg->kg_upquantum;
|
||||
/*
|
||||
@ -1674,8 +1664,8 @@ thread_userret(struct thread *td, struct trapframe *frame)
|
||||
CTR3(KTR_PROC, "userret: upcall thread %p (pid %d, %s)",
|
||||
td, td->td_proc->p_pid, td->td_proc->p_comm);
|
||||
|
||||
td->td_pflags &= ~TDP_UPCALLING;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
td->td_flags &= ~TDF_UPCALLING;
|
||||
if (ku->ku_flags & KUF_DOUPCALL)
|
||||
ku->ku_flags &= ~KUF_DOUPCALL;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
@ -339,7 +339,6 @@ struct thread {
|
||||
#define TDF_IDLETD 0x000020 /* This is one of the per-CPU idle threads */
|
||||
#define TDF_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */
|
||||
#define TDF_CVWAITQ 0x000080 /* Thread is on a cv_waitq (not slpq). */
|
||||
#define TDF_UPCALLING 0x000100 /* This thread is doing an upcall. */
|
||||
#define TDF_ONSLEEPQ 0x000200 /* On the sleep queue. */
|
||||
#define TDF_ASTPENDING 0x000800 /* Thread has some asynchronous events. */
|
||||
#define TDF_TIMOFAIL 0x001000 /* Timeout from sleep after we were awake. */
|
||||
@ -348,12 +347,14 @@ struct thread {
|
||||
#define TDF_OWEUPC 0x008000 /* Owe thread an addupc() call at next AST. */
|
||||
#define TDF_NEEDRESCHED 0x010000 /* Thread needs to yield. */
|
||||
#define TDF_NEEDSIGCHK 0x020000 /* Thread may need signal delivery. */
|
||||
#define TDF_SA 0x040000 /* A scheduler activation based thread */
|
||||
#define TDF_DEADLKTREAT 0x800000 /* Lock aquisition - deadlock treatment. */
|
||||
|
||||
/* "private" flags kept in td_pflags */
|
||||
#define TDP_OLDMASK 0x0001 /* Need to restore mask after suspend. */
|
||||
#define TDP_INKTR 0x0002 /* Thread is currently in KTR code. */
|
||||
#define TDP_INKTRACE 0x0004 /* Thread is currently in KTRACE code. */
|
||||
#define TDP_UPCALLING 0x0008 /* This thread is doing an upcall. */
|
||||
|
||||
#define TDI_SUSPENDED 0x0001 /* On suspension queue. */
|
||||
#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */
|
||||
|
Loading…
Reference in New Issue
Block a user