kern_sx.c (255745) | kern_sx.c (255788) |
---|---|
1/*- 2 * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> 3 * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 28 unchanged lines hidden (view full) --- 37 */ 38 39#include "opt_ddb.h" 40#include "opt_hwpmc_hooks.h" 41#include "opt_kdtrace.h" 42#include "opt_no_adaptive_sx.h" 43 44#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> 3 * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 28 unchanged lines hidden (view full) --- 37 */ 38 39#include "opt_ddb.h" 40#include "opt_hwpmc_hooks.h" 41#include "opt_kdtrace.h" 42#include "opt_no_adaptive_sx.h" 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 255745 2013-09-20 23:06:21Z davide $"); | 45__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 255788 2013-09-22 14:09:07Z davide $"); |
46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/kdb.h> 50#include <sys/ktr.h> 51#include <sys/lock.h> 52#include <sys/mutex.h> 53#include <sys/proc.h> --- 103 unchanged lines hidden (view full) --- 157 158void 159lock_sx(struct lock_object *lock, uintptr_t how) 160{ 161 struct sx *sx; 162 163 sx = (struct sx *)lock; 164 if (how) | 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/kdb.h> 50#include <sys/ktr.h> 51#include <sys/lock.h> 52#include <sys/mutex.h> 53#include <sys/proc.h> --- 103 unchanged lines hidden (view full) --- 157 158void 159lock_sx(struct lock_object *lock, uintptr_t how) 160{ 161 struct sx *sx; 162 163 sx = (struct sx *)lock; 164 if (how) |
165 sx_xlock(sx); 166 else | |
167 sx_slock(sx); | 165 sx_slock(sx); |
166 else 167 sx_xlock(sx); |
|
168} 169 170uintptr_t 171unlock_sx(struct lock_object *lock) 172{ 173 struct sx *sx; 174 175 sx = (struct sx *)lock; 176 sx_assert(sx, SA_LOCKED | SA_NOTRECURSED); 177 if (sx_xlocked(sx)) { 178 sx_xunlock(sx); | 168} 169 170uintptr_t 171unlock_sx(struct lock_object *lock) 172{ 173 struct sx *sx; 174 175 sx = (struct sx *)lock; 176 sx_assert(sx, SA_LOCKED | SA_NOTRECURSED); 177 if (sx_xlocked(sx)) { 178 sx_xunlock(sx); |
179 return (1); | 179 return (0); |
180 } else { 181 sx_sunlock(sx); | 180 } else { 181 sx_sunlock(sx); |
182 return (0); | 182 return (1); |
183 } 184} 185 186#ifdef KDTRACE_HOOKS 187int 188owner_sx(const struct lock_object *lock, struct thread **owner) 189{ 190 const struct sx *sx = (const struct sx *)lock; --- 1024 unchanged lines hidden --- | 183 } 184} 185 186#ifdef KDTRACE_HOOKS 187int 188owner_sx(const struct lock_object *lock, struct thread **owner) 189{ 190 const struct sx *sx = (const struct sx *)lock; --- 1024 unchanged lines hidden --- |