sched_4bsd.c (174536) | sched_4bsd.c (174629) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 19 unchanged lines hidden (view full) --- 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 174536 2007-12-11 08:25:36Z davidxu $"); | 36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 174629 2007-12-15 23:13:31Z jeff $"); |
37 38#include "opt_hwpmc_hooks.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/ktr.h> 44#include <sys/lock.h> --- 828 unchanged lines hidden (view full) --- 873 } 874 MPASS(newtd->td_lock == &sched_lock); 875 876 if (td != newtd) { 877#ifdef HWPMC_HOOKS 878 if (PMC_PROC_IS_USING_PMCS(td->td_proc)) 879 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT); 880#endif | 37 38#include "opt_hwpmc_hooks.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/ktr.h> 44#include <sys/lock.h> --- 828 unchanged lines hidden (view full) --- 873 } 874 MPASS(newtd->td_lock == &sched_lock); 875 876 if (td != newtd) { 877#ifdef HWPMC_HOOKS 878 if (PMC_PROC_IS_USING_PMCS(td->td_proc)) 879 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT); 880#endif |
881 | |
882 /* I feel sleepy */ | 881 /* I feel sleepy */ |
882 lock_profile_release_lock(&sched_lock.lock_object); |
|
883 cpu_switch(td, newtd, td->td_lock); | 883 cpu_switch(td, newtd, td->td_lock); |
884 lock_profile_obtain_lock_success(&sched_lock.lock_object, 885 0, 0, __FILE__, __LINE__); |
|
884 /* 885 * Where am I? What year is it? 886 * We are in the same thread that went to sleep above, 887 * but any amount of time may have passed. All out context 888 * will still be available as will local variables. 889 * PCPU values however may have changed as we may have 890 * changed CPU so don't trust cached values of them. 891 * New threads will go to fork_exit() instead of here --- 478 unchanged lines hidden (view full) --- 1370 * is now 2 rather than 1. Since we are nested, calling 1371 * spinlock_exit() will simply adjust the counts without allowing 1372 * spin lock using code to interrupt us. 1373 */ 1374 if (td == NULL) { 1375 mtx_lock_spin(&sched_lock); 1376 spinlock_exit(); 1377 } else { | 886 /* 887 * Where am I? What year is it? 888 * We are in the same thread that went to sleep above, 889 * but any amount of time may have passed. All out context 890 * will still be available as will local variables. 891 * PCPU values however may have changed as we may have 892 * changed CPU so don't trust cached values of them. 893 * New threads will go to fork_exit() instead of here --- 478 unchanged lines hidden (view full) --- 1372 * is now 2 rather than 1. Since we are nested, calling 1373 * spinlock_exit() will simply adjust the counts without allowing 1374 * spin lock using code to interrupt us. 1375 */ 1376 if (td == NULL) { 1377 mtx_lock_spin(&sched_lock); 1378 spinlock_exit(); 1379 } else { |
1380 lock_profile_release_lock(&sched_lock.lock_object); |
|
1378 MPASS(td->td_lock == &sched_lock); 1379 } 1380 mtx_assert(&sched_lock, MA_OWNED); 1381 KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); 1382 PCPU_SET(switchtime, cpu_ticks()); 1383 PCPU_SET(switchticks, ticks); 1384 cpu_throw(td, choosethread()); /* doesn't return */ 1385} 1386 1387void 1388sched_fork_exit(struct thread *td) 1389{ 1390 1391 /* 1392 * Finish setting up thread glue so that it begins execution in a 1393 * non-nested critical section with sched_lock held but not recursed. 1394 */ 1395 td->td_oncpu = PCPU_GET(cpuid); 1396 sched_lock.mtx_lock = (uintptr_t)td; | 1381 MPASS(td->td_lock == &sched_lock); 1382 } 1383 mtx_assert(&sched_lock, MA_OWNED); 1384 KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); 1385 PCPU_SET(switchtime, cpu_ticks()); 1386 PCPU_SET(switchticks, ticks); 1387 cpu_throw(td, choosethread()); /* doesn't return */ 1388} 1389 1390void 1391sched_fork_exit(struct thread *td) 1392{ 1393 1394 /* 1395 * Finish setting up thread glue so that it begins execution in a 1396 * non-nested critical section with sched_lock held but not recursed. 1397 */ 1398 td->td_oncpu = PCPU_GET(cpuid); 1399 sched_lock.mtx_lock = (uintptr_t)td; |
1400 lock_profile_obtain_lock_success(&sched_lock.lock_object, 1401 0, 0, __FILE__, __LINE__); |
|
1397 THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); 1398} 1399 1400#define KERN_SWITCH_INCLUDE 1 1401#include "kern/kern_switch.c" | 1402 THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); 1403} 1404 1405#define KERN_SWITCH_INCLUDE 1 1406#include "kern/kern_switch.c" |