kern_thread.c (178272) | kern_thread.c (181334) |
---|---|
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 178272 2008-04-17 04:20:10Z jeff $"); | 30__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 181334 2008-08-05 20:02:31Z jhb $"); |
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> --- 464 unchanged lines hidden (view full) --- 503 * any sleeping threads that are interruptable. (PCATCH). 504 */ 505int 506thread_single(int mode) 507{ 508 struct thread *td; 509 struct thread *td2; 510 struct proc *p; | 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> --- 464 unchanged lines hidden (view full) --- 503 * any sleeping threads that are interruptable. (PCATCH). 504 */ 505int 506thread_single(int mode) 507{ 508 struct thread *td; 509 struct thread *td2; 510 struct proc *p; |
511 int remaining; | 511 int remaining, wakeup_swapper; |
512 513 td = curthread; 514 p = td->td_proc; 515 mtx_assert(&Giant, MA_NOTOWNED); 516 PROC_LOCK_ASSERT(p, MA_OWNED); 517 KASSERT((td != NULL), ("curthread is NULL")); 518 519 if ((p->p_flag & P_HADTHREADS) == 0) --- 20 unchanged lines hidden (view full) --- 540 remaining = p->p_numthreads; 541 else if (mode == SINGLE_BOUNDARY) 542 remaining = p->p_numthreads - p->p_boundary_count; 543 else 544 remaining = p->p_numthreads - p->p_suspcount; 545 while (remaining != 1) { 546 if (P_SHOULDSTOP(p) != P_STOPPED_SINGLE) 547 goto stopme; | 512 513 td = curthread; 514 p = td->td_proc; 515 mtx_assert(&Giant, MA_NOTOWNED); 516 PROC_LOCK_ASSERT(p, MA_OWNED); 517 KASSERT((td != NULL), ("curthread is NULL")); 518 519 if ((p->p_flag & P_HADTHREADS) == 0) --- 20 unchanged lines hidden (view full) --- 540 remaining = p->p_numthreads; 541 else if (mode == SINGLE_BOUNDARY) 542 remaining = p->p_numthreads - p->p_boundary_count; 543 else 544 remaining = p->p_numthreads - p->p_suspcount; 545 while (remaining != 1) { 546 if (P_SHOULDSTOP(p) != P_STOPPED_SINGLE) 547 goto stopme; |
548 wakeup_swapper = 0; |
|
548 FOREACH_THREAD_IN_PROC(p, td2) { 549 if (td2 == td) 550 continue; 551 thread_lock(td2); 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) && 561 (td2->td_flags & TDF_SINTR)) | 549 FOREACH_THREAD_IN_PROC(p, td2) { 550 if (td2 == td) 551 continue; 552 thread_lock(td2); 553 td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; 554 if (TD_IS_INHIBITED(td2)) { 555 switch (mode) { 556 case SINGLE_EXIT: 557 if (td->td_flags & TDF_DBSUSPEND) 558 td->td_flags &= ~TDF_DBSUSPEND; 559 if (TD_IS_SUSPENDED(td2)) 560 thread_unsuspend_one(td2); 561 if (TD_ON_SLEEPQ(td2) && 562 (td2->td_flags & TDF_SINTR)) |
562 sleepq_abort(td2, EINTR); | 563 wakeup_swapper = 564 sleepq_abort(td2, EINTR); |
563 break; 564 case SINGLE_BOUNDARY: 565 break; 566 default: 567 if (TD_IS_SUSPENDED(td2)) { 568 thread_unlock(td2); 569 continue; 570 } --- 9 unchanged lines hidden (view full) --- 580 } 581#ifdef SMP 582 else if (TD_IS_RUNNING(td2) && td != td2) { 583 forward_signal(td2); 584 } 585#endif 586 thread_unlock(td2); 587 } | 565 break; 566 case SINGLE_BOUNDARY: 567 break; 568 default: 569 if (TD_IS_SUSPENDED(td2)) { 570 thread_unlock(td2); 571 continue; 572 } --- 9 unchanged lines hidden (view full) --- 582 } 583#ifdef SMP 584 else if (TD_IS_RUNNING(td2) && td != td2) { 585 forward_signal(td2); 586 } 587#endif 588 thread_unlock(td2); 589 } |
590 if (wakeup_swapper) 591 kick_proc0(); |
|
588 if (mode == SINGLE_EXIT) 589 remaining = p->p_numthreads; 590 else if (mode == SINGLE_BOUNDARY) 591 remaining = p->p_numthreads - p->p_boundary_count; 592 else 593 remaining = p->p_numthreads - p->p_suspcount; 594 595 /* --- 186 unchanged lines hidden (view full) --- 782{ 783 struct proc *p = td->td_proc; 784 785 PROC_SLOCK_ASSERT(p, MA_OWNED); 786 THREAD_LOCK_ASSERT(td, MA_OWNED); 787 KASSERT(TD_IS_SUSPENDED(td), ("Thread not suspended")); 788 TD_CLR_SUSPENDED(td); 789 p->p_suspcount--; | 592 if (mode == SINGLE_EXIT) 593 remaining = p->p_numthreads; 594 else if (mode == SINGLE_BOUNDARY) 595 remaining = p->p_numthreads - p->p_boundary_count; 596 else 597 remaining = p->p_numthreads - p->p_suspcount; 598 599 /* --- 186 unchanged lines hidden (view full) --- 786{ 787 struct proc *p = td->td_proc; 788 789 PROC_SLOCK_ASSERT(p, MA_OWNED); 790 THREAD_LOCK_ASSERT(td, MA_OWNED); 791 KASSERT(TD_IS_SUSPENDED(td), ("Thread not suspended")); 792 TD_CLR_SUSPENDED(td); 793 p->p_suspcount--; |
790 setrunnable(td); | 794 if (setrunnable(td)) { 795#ifdef INVARIANTS 796 panic("not waking up swapper"); 797#endif 798 } |
791} 792 793/* 794 * Allow all threads blocked by single threading to continue running. 795 */ 796void 797thread_unsuspend(struct proc *p) 798{ --- 70 unchanged lines hidden --- | 799} 800 801/* 802 * Allow all threads blocked by single threading to continue running. 803 */ 804void 805thread_unsuspend(struct proc *p) 806{ --- 70 unchanged lines hidden --- |