kern_rwlock.c (182909) | kern_rwlock.c (182914) |
---|---|
1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 182909 2008-09-10 17:59:21Z jhb $"); | 35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 182914 2008-09-10 19:13:30Z jhb $"); |
36 37#include "opt_ddb.h" 38#include "opt_no_adaptive_rwlocks.h" 39 40#include <sys/param.h> 41#include <sys/ktr.h> 42#include <sys/kernel.h> 43#include <sys/lock.h> --- 157 unchanged lines hidden (view full) --- 201void 202_rw_wlock(struct rwlock *rw, const char *file, int line) 203{ 204 205 MPASS(curthread != NULL); 206 KASSERT(rw->rw_lock != RW_DESTROYED, 207 ("rw_wlock() of destroyed rwlock @ %s:%d", file, line)); 208 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file, | 36 37#include "opt_ddb.h" 38#include "opt_no_adaptive_rwlocks.h" 39 40#include <sys/param.h> 41#include <sys/ktr.h> 42#include <sys/kernel.h> 43#include <sys/lock.h> --- 157 unchanged lines hidden (view full) --- 201void 202_rw_wlock(struct rwlock *rw, const char *file, int line) 203{ 204 205 MPASS(curthread != NULL); 206 KASSERT(rw->rw_lock != RW_DESTROYED, 207 ("rw_wlock() of destroyed rwlock @ %s:%d", file, line)); 208 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file, |
209 line); | 209 line, NULL); |
210 __rw_wlock(rw, curthread, file, line); 211 LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line); 212 WITNESS_LOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line); 213 curthread->td_locks++; 214} 215 216int 217_rw_try_wlock(struct rwlock *rw, const char *file, int line) --- 60 unchanged lines hidden (view full) --- 278 int contested = 0; 279 uintptr_t v; 280 281 KASSERT(rw->rw_lock != RW_DESTROYED, 282 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); 283 KASSERT(rw_wowner(rw) != curthread, 284 ("%s (%s): wlock already held @ %s:%d", __func__, 285 rw->lock_object.lo_name, file, line)); | 210 __rw_wlock(rw, curthread, file, line); 211 LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line); 212 WITNESS_LOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line); 213 curthread->td_locks++; 214} 215 216int 217_rw_try_wlock(struct rwlock *rw, const char *file, int line) --- 60 unchanged lines hidden (view full) --- 278 int contested = 0; 279 uintptr_t v; 280 281 KASSERT(rw->rw_lock != RW_DESTROYED, 282 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); 283 KASSERT(rw_wowner(rw) != curthread, 284 ("%s (%s): wlock already held @ %s:%d", __func__, 285 rw->lock_object.lo_name, file, line)); |
286 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line); | 286 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL); |
287 288 for (;;) { 289 /* 290 * Handle the easy case. If no other thread has a write 291 * lock, then try to bump up the count of read locks. Note 292 * that we have to preserve the current state of the 293 * RW_LOCK_WRITE_WAITERS flag. If we fail to acquire a 294 * read lock, then rw_lock must have changed, so restart --- 736 unchanged lines hidden --- | 287 288 for (;;) { 289 /* 290 * Handle the easy case. If no other thread has a write 291 * lock, then try to bump up the count of read locks. Note 292 * that we have to preserve the current state of the 293 * RW_LOCK_WRITE_WAITERS flag. If we fail to acquire a 294 * read lock, then rw_lock must have changed, so restart --- 736 unchanged lines hidden --- |