Deleted Added
full compact
kern_mutex.c (86411) kern_mutex.c (88088)
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 86411 2001-11-15 19:08:55Z jhb $
30 * $FreeBSD: head/sys/kern/kern_mutex.c 88088 2001-12-18 00:27:18Z jhb $
31 */
32
33/*
34 * Machine independent bits of mutex implementation.
35 */
36
37#include "opt_ddb.h"
38

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

422
423/*
424 * _mtx_lock_spin: the tougher part of acquiring an MTX_SPIN lock.
425 *
426 * This is only called if we need to actually spin for the lock. Recursion
427 * is handled inline.
428 */
429void
31 */
32
33/*
34 * Machine independent bits of mutex implementation.
35 */
36
37#include "opt_ddb.h"
38

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

422
423/*
424 * _mtx_lock_spin: the tougher part of acquiring an MTX_SPIN lock.
425 *
426 * This is only called if we need to actually spin for the lock. Recursion
427 * is handled inline.
428 */
429void
430_mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file,
431 int line)
430_mtx_lock_spin(struct mtx *m, int opts, const char *file, int line)
432{
433 int i = 0;
434
435 if (LOCK_LOG_TEST(&m->mtx_object, opts))
436 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);
437
438 for (;;) {
439 if (_obtain_lock(m, curthread))
440 break;
441
442 /* Give interrupts a chance while we spin. */
431{
432 int i = 0;
433
434 if (LOCK_LOG_TEST(&m->mtx_object, opts))
435 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);
436
437 for (;;) {
438 if (_obtain_lock(m, curthread))
439 break;
440
441 /* Give interrupts a chance while we spin. */
443 critical_exit(mtx_crit);
442 critical_exit();
444 while (m->mtx_lock != MTX_UNOWNED) {
445 if (i++ < 1000000)
446 continue;
447 if (i++ < 6000000)
448 DELAY(1);
449#ifdef DDB
450 else if (!db_active)
451#else
452 else
453#endif
454 panic("spin lock %s held by %p for > 5 seconds",
455 m->mtx_object.lo_name, (void *)m->mtx_lock);
456 }
443 while (m->mtx_lock != MTX_UNOWNED) {
444 if (i++ < 1000000)
445 continue;
446 if (i++ < 6000000)
447 DELAY(1);
448#ifdef DDB
449 else if (!db_active)
450#else
451 else
452#endif
453 panic("spin lock %s held by %p for > 5 seconds",
454 m->mtx_object.lo_name, (void *)m->mtx_lock);
455 }
457 mtx_crit = critical_enter();
456 critical_enter();
458 }
459
457 }
458
460 m->mtx_savecrit = mtx_crit;
461 if (LOCK_LOG_TEST(&m->mtx_object, opts))
462 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m);
463
464 return;
465}
466
467/*
468 * _mtx_unlock_sleep: the tougher part of releasing an MTX_DEF lock.

--- 275 unchanged lines hidden ---
459 if (LOCK_LOG_TEST(&m->mtx_object, opts))
460 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m);
461
462 return;
463}
464
465/*
466 * _mtx_unlock_sleep: the tougher part of releasing an MTX_DEF lock.

--- 275 unchanged lines hidden ---