kern_mutex.c (254139) | kern_mutex.c (255745) |
---|---|
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 254139 2013-08-09 11:24:29Z attilio $"); | 37__FBSDID("$FreeBSD: head/sys/kern/kern_mutex.c 255745 2013-09-20 23:06:21Z davide $"); |
38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_hwpmc_hooks.h" 43#include "opt_kdtrace.h" 44#include "opt_sched.h" 45 --- 50 unchanged lines hidden (view full) --- 96#define mtx_destroyed(m) ((m)->mtx_lock == MTX_DESTROYED) 97 98#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK)) 99 100static void assert_mtx(const struct lock_object *lock, int what); 101#ifdef DDB 102static void db_show_mtx(const struct lock_object *lock); 103#endif | 38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_hwpmc_hooks.h" 43#include "opt_kdtrace.h" 44#include "opt_sched.h" 45 --- 50 unchanged lines hidden (view full) --- 96#define mtx_destroyed(m) ((m)->mtx_lock == MTX_DESTROYED) 97 98#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK)) 99 100static void assert_mtx(const struct lock_object *lock, int what); 101#ifdef DDB 102static void db_show_mtx(const struct lock_object *lock); 103#endif |
104static void lock_mtx(struct lock_object *lock, int how); 105static void lock_spin(struct lock_object *lock, int how); | 104static void lock_mtx(struct lock_object *lock, uintptr_t how); 105static void lock_spin(struct lock_object *lock, uintptr_t how); |
106#ifdef KDTRACE_HOOKS 107static int owner_mtx(const struct lock_object *lock, 108 struct thread **owner); 109#endif | 106#ifdef KDTRACE_HOOKS 107static int owner_mtx(const struct lock_object *lock, 108 struct thread **owner); 109#endif |
110static int unlock_mtx(struct lock_object *lock); 111static int unlock_spin(struct lock_object *lock); | 110static uintptr_t unlock_mtx(struct lock_object *lock); 111static uintptr_t unlock_spin(struct lock_object *lock); |
112 113/* 114 * Lock classes for sleep and spin mutexes. 115 */ 116struct lock_class lock_class_mtx_sleep = { 117 .lc_name = "sleep mutex", 118 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, 119 .lc_assert = assert_mtx, --- 29 unchanged lines hidden (view full) --- 149void 150assert_mtx(const struct lock_object *lock, int what) 151{ 152 153 mtx_assert((const struct mtx *)lock, what); 154} 155 156void | 112 113/* 114 * Lock classes for sleep and spin mutexes. 115 */ 116struct lock_class lock_class_mtx_sleep = { 117 .lc_name = "sleep mutex", 118 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, 119 .lc_assert = assert_mtx, --- 29 unchanged lines hidden (view full) --- 149void 150assert_mtx(const struct lock_object *lock, int what) 151{ 152 153 mtx_assert((const struct mtx *)lock, what); 154} 155 156void |
157lock_mtx(struct lock_object *lock, int how) | 157lock_mtx(struct lock_object *lock, uintptr_t how) |
158{ 159 160 mtx_lock((struct mtx *)lock); 161} 162 163void | 158{ 159 160 mtx_lock((struct mtx *)lock); 161} 162 163void |
164lock_spin(struct lock_object *lock, int how) | 164lock_spin(struct lock_object *lock, uintptr_t how) |
165{ 166 167 panic("spin locks can only use msleep_spin"); 168} 169 | 165{ 166 167 panic("spin locks can only use msleep_spin"); 168} 169 |
170int | 170uintptr_t |
171unlock_mtx(struct lock_object *lock) 172{ 173 struct mtx *m; 174 175 m = (struct mtx *)lock; 176 mtx_assert(m, MA_OWNED | MA_NOTRECURSED); 177 mtx_unlock(m); 178 return (0); 179} 180 | 171unlock_mtx(struct lock_object *lock) 172{ 173 struct mtx *m; 174 175 m = (struct mtx *)lock; 176 mtx_assert(m, MA_OWNED | MA_NOTRECURSED); 177 mtx_unlock(m); 178 return (0); 179} 180 |
181int | 181uintptr_t |
182unlock_spin(struct lock_object *lock) 183{ 184 185 panic("spin locks can only use msleep_spin"); 186} 187 188#ifdef KDTRACE_HOOKS 189int --- 820 unchanged lines hidden --- | 182unlock_spin(struct lock_object *lock) 183{ 184 185 panic("spin locks can only use msleep_spin"); 186} 187 188#ifdef KDTRACE_HOOKS 189int --- 820 unchanged lines hidden --- |