Deleted Added
full compact
kern_mutex.c (88088) kern_mutex.c (88900)
1/*-
2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER 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
26 * SUCH DAMAGE.
27 *
28 * from BSDI $Id: mutex_witness.c,v 1.1.2.20 2000/04/27 03:10:27 cp Exp $
29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $
1/*-
2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER 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
26 * SUCH DAMAGE.
27 *
28 * from BSDI $Id: mutex_witness.c,v 1.1.2.20 2000/04/27 03:10:27 cp Exp $
29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $
30 * $FreeBSD: head/sys/kern/kern_mutex.c 88088 2001-12-18 00:27:18Z jhb $
30 * $FreeBSD: head/sys/kern/kern_mutex.c 88900 2002-01-05 08:47:13Z jhb $
31 */
32
33/*
34 * Machine independent bits of mutex implementation.
35 */
36
37#include "opt_ddb.h"
38

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

204 * Function versions of the inlined __mtx_* macros. These are used by
205 * modules and can also be called from assembly language if needed.
206 */
207void
208_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
209{
210
211 MPASS(curthread != NULL);
31 */
32
33/*
34 * Machine independent bits of mutex implementation.
35 */
36
37#include "opt_ddb.h"
38

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

204 * Function versions of the inlined __mtx_* macros. These are used by
205 * modules and can also be called from assembly language if needed.
206 */
207void
208_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
209{
210
211 MPASS(curthread != NULL);
212 KASSERT((opts & MTX_NOSWITCH) == 0,
213 ("MTX_NOSWITCH used at %s:%d", file, line));
214 _get_sleep_lock(m, curthread, opts, file, line);
215 LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
216 line);
217 WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
218}
219
220void
221_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)

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

259 */
260int
261_mtx_trylock(struct mtx *m, int opts, const char *file, int line)
262{
263 int rval;
264
265 MPASS(curthread != NULL);
266
212 _get_sleep_lock(m, curthread, opts, file, line);
213 LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
214 line);
215 WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
216}
217
218void
219_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)

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

257 */
258int
259_mtx_trylock(struct mtx *m, int opts, const char *file, int line)
260{
261 int rval;
262
263 MPASS(curthread != NULL);
264
267 /*
268 * _mtx_trylock does not accept MTX_NOSWITCH option.
269 */
270 KASSERT((opts & MTX_NOSWITCH) == 0,
271 ("mtx_trylock() called with invalid option flag(s) %d", opts));
272
273 rval = _obtain_lock(m, curthread);
274
275 LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
276 if (rval) {
277 /*
278 * We do not handle recursion in _mtx_trylock; see the
279 * note at the top of the routine.
280 */

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

519 if (LOCK_LOG_TEST(&m->mtx_object, opts))
520 CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p contested setrunqueue %p",
521 m, td1);
522
523 td1->td_blocked = NULL;
524 td1->td_proc->p_stat = SRUN;
525 setrunqueue(td1);
526
265 rval = _obtain_lock(m, curthread);
266
267 LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
268 if (rval) {
269 /*
270 * We do not handle recursion in _mtx_trylock; see the
271 * note at the top of the routine.
272 */

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

511 if (LOCK_LOG_TEST(&m->mtx_object, opts))
512 CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p contested setrunqueue %p",
513 m, td1);
514
515 td1->td_blocked = NULL;
516 td1->td_proc->p_stat = SRUN;
517 setrunqueue(td1);
518
527 if ((opts & MTX_NOSWITCH) == 0 && td1->td_ksegrp->kg_pri.pri_level < pri) {
519 if (td->td_critnest == 1 && td1->td_ksegrp->kg_pri.pri_level < pri) {
528#ifdef notyet
529 if (td->td_ithd != NULL) {
530 struct ithd *it = td->td_ithd;
531
532 if (it->it_interrupted) {
533 if (LOCK_LOG_TEST(&m->mtx_object, opts))
534 CTR2(KTR_LOCK,
535 "_mtx_unlock_sleep: %p interrupted %p",

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

686 LOCK_LOG_DESTROY(&m->mtx_object, 0);
687
688 if (!mtx_owned(m))
689 MPASS(mtx_unowned(m));
690 else {
691 MPASS((m->mtx_lock & (MTX_RECURSED|MTX_CONTESTED)) == 0);
692
693 /* Tell witness this isn't locked to make it happy. */
520#ifdef notyet
521 if (td->td_ithd != NULL) {
522 struct ithd *it = td->td_ithd;
523
524 if (it->it_interrupted) {
525 if (LOCK_LOG_TEST(&m->mtx_object, opts))
526 CTR2(KTR_LOCK,
527 "_mtx_unlock_sleep: %p interrupted %p",

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

678 LOCK_LOG_DESTROY(&m->mtx_object, 0);
679
680 if (!mtx_owned(m))
681 MPASS(mtx_unowned(m));
682 else {
683 MPASS((m->mtx_lock & (MTX_RECURSED|MTX_CONTESTED)) == 0);
684
685 /* Tell witness this isn't locked to make it happy. */
694 WITNESS_UNLOCK(&m->mtx_object, LOP_EXCLUSIVE | LOP_NOSWITCH,
695 __FILE__, __LINE__);
686 WITNESS_UNLOCK(&m->mtx_object, LOP_EXCLUSIVE, __FILE__,
687 __LINE__);
696 }
697
698 WITNESS_DESTROY(&m->mtx_object);
699}
700
701/*
702 * Encapsulated Giant mutex routines. These routines provide encapsulation
703 * control for the Giant mutex, allowing sysctls to be used to turn on and

--- 38 unchanged lines hidden ---
688 }
689
690 WITNESS_DESTROY(&m->mtx_object);
691}
692
693/*
694 * Encapsulated Giant mutex routines. These routines provide encapsulation
695 * control for the Giant mutex, allowing sysctls to be used to turn on and

--- 38 unchanged lines hidden ---