kern_sx.c (173600) | kern_sx.c (173733) |
---|---|
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: --- 26 unchanged lines hidden (view full) --- 35 * Priority propagation will not generally raise the priority of lock holders, 36 * so should not be relied upon in combination with sx locks. 37 */ 38 39#include "opt_adaptive_sx.h" 40#include "opt_ddb.h" 41 42#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: --- 26 unchanged lines hidden (view full) --- 35 * Priority propagation will not generally raise the priority of lock holders, 36 * so should not be relied upon in combination with sx locks. 37 */ 38 39#include "opt_adaptive_sx.h" 40#include "opt_ddb.h" 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 173600 2007-11-14 06:21:24Z julian $"); | 43__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 173733 2007-11-18 14:43:53Z attilio $"); |
44 45#include <sys/param.h> 46#include <sys/ktr.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> 49#include <sys/proc.h> 50#include <sys/sleepqueue.h> 51#include <sys/sx.h> --- 46 unchanged lines hidden (view full) --- 98} while (0) 99 100/* 101 * Returns true if an exclusive lock is recursed. It assumes 102 * curthread currently has an exclusive lock. 103 */ 104#define sx_recursed(sx) ((sx)->sx_recurse != 0) 105 | 44 45#include <sys/param.h> 46#include <sys/ktr.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> 49#include <sys/proc.h> 50#include <sys/sleepqueue.h> 51#include <sys/sx.h> --- 46 unchanged lines hidden (view full) --- 98} while (0) 99 100/* 101 * Returns true if an exclusive lock is recursed. It assumes 102 * curthread currently has an exclusive lock. 103 */ 104#define sx_recursed(sx) ((sx)->sx_recurse != 0) 105 |
106static void assert_sx(struct lock_object *lock, int what); |
|
106#ifdef DDB 107static void db_show_sx(struct lock_object *lock); 108#endif 109static void lock_sx(struct lock_object *lock, int how); 110static int unlock_sx(struct lock_object *lock); 111 112struct lock_class lock_class_sx = { 113 .lc_name = "sx", 114 .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE, | 107#ifdef DDB 108static void db_show_sx(struct lock_object *lock); 109#endif 110static void lock_sx(struct lock_object *lock, int how); 111static int unlock_sx(struct lock_object *lock); 112 113struct lock_class lock_class_sx = { 114 .lc_name = "sx", 115 .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE, |
116 .lc_assert = assert_sx, |
|
115#ifdef DDB 116 .lc_ddb_show = db_show_sx, 117#endif 118 .lc_lock = lock_sx, 119 .lc_unlock = unlock_sx, 120}; 121 122#ifndef INVARIANTS 123#define _sx_assert(sx, what, file, line) 124#endif 125 126void | 117#ifdef DDB 118 .lc_ddb_show = db_show_sx, 119#endif 120 .lc_lock = lock_sx, 121 .lc_unlock = unlock_sx, 122}; 123 124#ifndef INVARIANTS 125#define _sx_assert(sx, what, file, line) 126#endif 127 128void |
129assert_sx(struct lock_object *lock, int what) 130{ 131 132 sx_assert((struct sx *)lock, what); 133} 134 135void |
|
127lock_sx(struct lock_object *lock, int how) 128{ 129 struct sx *sx; 130 131 sx = (struct sx *)lock; 132 if (how) 133 sx_xlock(sx); 134 else --- 907 unchanged lines hidden --- | 136lock_sx(struct lock_object *lock, int how) 137{ 138 struct sx *sx; 139 140 sx = (struct sx *)lock; 141 if (how) 142 sx_xlock(sx); 143 else --- 907 unchanged lines hidden --- |