kern_mutex.c (173600) | kern_mutex.c (173733) |
---|---|
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. --- 20 unchanged lines hidden (view full) --- 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ 30 */ 31 32/* 33 * Machine independent bits of mutex implementation. 34 */ 35 36#include <sys/cdefs.h> | 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. --- 20 unchanged lines hidden (view full) --- 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ 30 */ 31 32/* 33 * Machine independent bits of mutex implementation. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/kern/kern_mutex.c 173600 2007-11-14 06:21:24Z julian $"); | 37__FBSDID("$FreeBSD: head/sys/kern/kern_mutex.c 173733 2007-11-18 14:43:53Z attilio $"); |
38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_sched.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> --- 33 unchanged lines hidden (view full) --- 79 * Internal utility macros. 80 */ 81#define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED) 82 83#define mtx_destroyed(m) ((m)->mtx_lock == MTX_DESTROYED) 84 85#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK)) 86 | 38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_sched.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> --- 33 unchanged lines hidden (view full) --- 79 * Internal utility macros. 80 */ 81#define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED) 82 83#define mtx_destroyed(m) ((m)->mtx_lock == MTX_DESTROYED) 84 85#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK)) 86 |
87static void assert_mtx(struct lock_object *lock, int what); |
|
87#ifdef DDB 88static void db_show_mtx(struct lock_object *lock); 89#endif 90static void lock_mtx(struct lock_object *lock, int how); 91static void lock_spin(struct lock_object *lock, int how); 92static int unlock_mtx(struct lock_object *lock); 93static int unlock_spin(struct lock_object *lock); 94 95/* 96 * Lock classes for sleep and spin mutexes. 97 */ 98struct lock_class lock_class_mtx_sleep = { 99 .lc_name = "sleep mutex", 100 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, | 88#ifdef DDB 89static void db_show_mtx(struct lock_object *lock); 90#endif 91static void lock_mtx(struct lock_object *lock, int how); 92static void lock_spin(struct lock_object *lock, int how); 93static int unlock_mtx(struct lock_object *lock); 94static int unlock_spin(struct lock_object *lock); 95 96/* 97 * Lock classes for sleep and spin mutexes. 98 */ 99struct lock_class lock_class_mtx_sleep = { 100 .lc_name = "sleep mutex", 101 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, |
102 .lc_assert = assert_mtx, |
|
101#ifdef DDB 102 .lc_ddb_show = db_show_mtx, 103#endif 104 .lc_lock = lock_mtx, 105 .lc_unlock = unlock_mtx, 106}; 107struct lock_class lock_class_mtx_spin = { 108 .lc_name = "spin mutex", 109 .lc_flags = LC_SPINLOCK | LC_RECURSABLE, | 103#ifdef DDB 104 .lc_ddb_show = db_show_mtx, 105#endif 106 .lc_lock = lock_mtx, 107 .lc_unlock = unlock_mtx, 108}; 109struct lock_class lock_class_mtx_spin = { 110 .lc_name = "spin mutex", 111 .lc_flags = LC_SPINLOCK | LC_RECURSABLE, |
112 .lc_assert = assert_mtx, |
|
110#ifdef DDB 111 .lc_ddb_show = db_show_mtx, 112#endif 113 .lc_lock = lock_spin, 114 .lc_unlock = unlock_spin, 115}; 116 117/* --- 12 unchanged lines hidden (view full) --- 130 NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE); 131 } 132} 133#else 134static inline void lock_profile_init(void) {;} 135#endif 136 137void | 113#ifdef DDB 114 .lc_ddb_show = db_show_mtx, 115#endif 116 .lc_lock = lock_spin, 117 .lc_unlock = unlock_spin, 118}; 119 120/* --- 12 unchanged lines hidden (view full) --- 133 NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE); 134 } 135} 136#else 137static inline void lock_profile_init(void) {;} 138#endif 139 140void |
141assert_mtx(struct lock_object *lock, int what) 142{ 143 144 mtx_assert((struct mtx *)lock, what); 145} 146 147void |
|
138lock_mtx(struct lock_object *lock, int how) 139{ 140 141 mtx_lock((struct mtx *)lock); 142} 143 144void 145lock_spin(struct lock_object *lock, int how) --- 682 unchanged lines hidden --- | 148lock_mtx(struct lock_object *lock, int how) 149{ 150 151 mtx_lock((struct mtx *)lock); 152} 153 154void 155lock_spin(struct lock_object *lock, int how) --- 682 unchanged lines hidden --- |