Deleted Added
full compact
kern_switch.c (172481) kern_switch.c (173600)
1/*-
2 * Copyright (c) 2001 Jake Burkholder <jake@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

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Jake Burkholder <jake@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

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/kern/kern_switch.c 172481 2007-10-08 23:37:28Z jeff $");
29__FBSDID("$FreeBSD: head/sys/kern/kern_switch.c 173600 2007-11-14 06:21:24Z julian $");
30
31#include "opt_sched.h"
32
33#ifndef KERN_SWITCH_INCLUDE
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kdb.h>
37#include <sys/kernel.h>

--- 120 unchanged lines hidden (view full) ---

158void
159critical_enter(void)
160{
161 struct thread *td;
162
163 td = curthread;
164 td->td_critnest++;
165 CTR4(KTR_CRITICAL, "critical_enter by thread %p (%ld, %s) to %d", td,
30
31#include "opt_sched.h"
32
33#ifndef KERN_SWITCH_INCLUDE
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kdb.h>
37#include <sys/kernel.h>

--- 120 unchanged lines hidden (view full) ---

158void
159critical_enter(void)
160{
161 struct thread *td;
162
163 td = curthread;
164 td->td_critnest++;
165 CTR4(KTR_CRITICAL, "critical_enter by thread %p (%ld, %s) to %d", td,
166 (long)td->td_proc->p_pid, td->td_proc->p_comm, td->td_critnest);
166 (long)td->td_proc->p_pid, td->td_name, td->td_critnest);
167}
168
169void
170critical_exit(void)
171{
172 struct thread *td;
173
174 td = curthread;

--- 9 unchanged lines hidden (view full) ---

184 SCHED_STAT_INC(switch_owepreempt);
185 mi_switch(SW_INVOL|SW_PREEMPT, NULL);
186 thread_unlock(td);
187 }
188 } else
189 td->td_critnest--;
190
191 CTR4(KTR_CRITICAL, "critical_exit by thread %p (%ld, %s) to %d", td,
167}
168
169void
170critical_exit(void)
171{
172 struct thread *td;
173
174 td = curthread;

--- 9 unchanged lines hidden (view full) ---

184 SCHED_STAT_INC(switch_owepreempt);
185 mi_switch(SW_INVOL|SW_PREEMPT, NULL);
186 thread_unlock(td);
187 }
188 } else
189 td->td_critnest--;
190
191 CTR4(KTR_CRITICAL, "critical_exit by thread %p (%ld, %s) to %d", td,
192 (long)td->td_proc->p_pid, td->td_proc->p_comm, td->td_critnest);
192 (long)td->td_proc->p_pid, td->td_name, td->td_critnest);
193}
194
195/*
196 * This function is called when a thread is about to be put on run queue
197 * because it has been made runnable or its priority has been adjusted. It
198 * determines if the new thread should be immediately preempted to. If so,
199 * it switches to it and eventually returns true. If not, it returns false
200 * so that the caller may place the thread on an appropriate run queue.

--- 54 unchanged lines hidden (view full) ---

255 }
256 /*
257 * Thread is runnable but not yet put on system run queue.
258 */
259 MPASS(ctd->td_lock == td->td_lock);
260 MPASS(TD_ON_RUNQ(td));
261 TD_SET_RUNNING(td);
262 CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td,
193}
194
195/*
196 * This function is called when a thread is about to be put on run queue
197 * because it has been made runnable or its priority has been adjusted. It
198 * determines if the new thread should be immediately preempted to. If so,
199 * it switches to it and eventually returns true. If not, it returns false
200 * so that the caller may place the thread on an appropriate run queue.

--- 54 unchanged lines hidden (view full) ---

255 }
256 /*
257 * Thread is runnable but not yet put on system run queue.
258 */
259 MPASS(ctd->td_lock == td->td_lock);
260 MPASS(TD_ON_RUNQ(td));
261 TD_SET_RUNNING(td);
262 CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td,
263 td->td_proc->p_pid, td->td_proc->p_comm);
263 td->td_proc->p_pid, td->td_name);
264 SCHED_STAT_INC(switch_preempt);
265 mi_switch(SW_INVOL|SW_PREEMPT, td);
266 /*
267 * td's lock pointer may have changed. We have to return with it
268 * locked.
269 */
270 spinlock_enter();
271 thread_unlock(ctd);

--- 339 unchanged lines hidden ---
264 SCHED_STAT_INC(switch_preempt);
265 mi_switch(SW_INVOL|SW_PREEMPT, td);
266 /*
267 * td's lock pointer may have changed. We have to return with it
268 * locked.
269 */
270 spinlock_enter();
271 thread_unlock(ctd);

--- 339 unchanged lines hidden ---