kern_thread.c (177427) | kern_thread.c (177471) |
---|---|
1/*- 2 * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 * DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 * DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 177427 2008-03-20 03:07:57Z jeff $"); | 30__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 177471 2008-03-21 08:23:25Z jeff $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> 37#include <sys/proc.h> 38#include <sys/resourcevar.h> --- 505 unchanged lines hidden (view full) --- 544 remaining = p->p_numthreads - p->p_suspcount; 545 while (remaining != 1) { 546 if (P_SHOULDSTOP(p) != P_STOPPED_SINGLE) 547 goto stopme; 548 FOREACH_THREAD_IN_PROC(p, td2) { 549 if (td2 == td) 550 continue; 551 thread_lock(td2); | 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> 37#include <sys/proc.h> 38#include <sys/resourcevar.h> --- 505 unchanged lines hidden (view full) --- 544 remaining = p->p_numthreads - p->p_suspcount; 545 while (remaining != 1) { 546 if (P_SHOULDSTOP(p) != P_STOPPED_SINGLE) 547 goto stopme; 548 FOREACH_THREAD_IN_PROC(p, td2) { 549 if (td2 == td) 550 continue; 551 thread_lock(td2); |
552 td2->td_flags |= TDF_ASTPENDING; | 552 td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; |
553 if (TD_IS_INHIBITED(td2)) { 554 switch (mode) { 555 case SINGLE_EXIT: 556 if (td->td_flags & TDF_DBSUSPEND) 557 td->td_flags &= ~TDF_DBSUSPEND; 558 if (TD_IS_SUSPENDED(td2)) 559 thread_unsuspend_one(td2); 560 if (TD_ON_SLEEPQ(td2) && --- 185 unchanged lines hidden (view full) --- 746 /* 747 * We implement thread_suspend_one in stages here to avoid 748 * dropping the proc lock while the thread lock is owned. 749 */ 750 thread_stopped(p); 751 p->p_suspcount++; 752 PROC_UNLOCK(p); 753 thread_lock(td); | 553 if (TD_IS_INHIBITED(td2)) { 554 switch (mode) { 555 case SINGLE_EXIT: 556 if (td->td_flags & TDF_DBSUSPEND) 557 td->td_flags &= ~TDF_DBSUSPEND; 558 if (TD_IS_SUSPENDED(td2)) 559 thread_unsuspend_one(td2); 560 if (TD_ON_SLEEPQ(td2) && --- 185 unchanged lines hidden (view full) --- 746 /* 747 * We implement thread_suspend_one in stages here to avoid 748 * dropping the proc lock while the thread lock is owned. 749 */ 750 thread_stopped(p); 751 p->p_suspcount++; 752 PROC_UNLOCK(p); 753 thread_lock(td); |
754 td->td_flags &= ~TDF_NEEDSUSPCHK; |
|
754 TD_SET_SUSPENDED(td); 755 sched_sleep(td, 0); 756 PROC_SUNLOCK(p); 757 DROP_GIANT(); 758 mi_switch(SW_VOL, NULL); 759 thread_unlock(td); 760 PICKUP_GIANT(); 761 PROC_LOCK(p); --- 4 unchanged lines hidden (view full) --- 766thread_suspend_one(struct thread *td) 767{ 768 struct proc *p = td->td_proc; 769 770 PROC_SLOCK_ASSERT(p, MA_OWNED); 771 THREAD_LOCK_ASSERT(td, MA_OWNED); 772 KASSERT(!TD_IS_SUSPENDED(td), ("already suspended")); 773 p->p_suspcount++; | 755 TD_SET_SUSPENDED(td); 756 sched_sleep(td, 0); 757 PROC_SUNLOCK(p); 758 DROP_GIANT(); 759 mi_switch(SW_VOL, NULL); 760 thread_unlock(td); 761 PICKUP_GIANT(); 762 PROC_LOCK(p); --- 4 unchanged lines hidden (view full) --- 767thread_suspend_one(struct thread *td) 768{ 769 struct proc *p = td->td_proc; 770 771 PROC_SLOCK_ASSERT(p, MA_OWNED); 772 THREAD_LOCK_ASSERT(td, MA_OWNED); 773 KASSERT(!TD_IS_SUSPENDED(td), ("already suspended")); 774 p->p_suspcount++; |
775 td->td_flags &= ~TDF_NEEDSUSPCHK; |
|
774 TD_SET_SUSPENDED(td); 775 sched_sleep(td, 0); 776} 777 778void 779thread_unsuspend_one(struct thread *td) 780{ 781 struct proc *p = td->td_proc; --- 85 unchanged lines hidden --- | 776 TD_SET_SUSPENDED(td); 777 sched_sleep(td, 0); 778} 779 780void 781thread_unsuspend_one(struct thread *td) 782{ 783 struct proc *p = td->td_proc; --- 85 unchanged lines hidden --- |