Page MenuHomeFreeBSD

D45745.diff
No OneTemporary

D45745.diff

diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -100,6 +100,8 @@
#endif
static void lock_mtx(struct lock_object *lock, uintptr_t how);
static void lock_spin(struct lock_object *lock, uintptr_t how);
+static int trylock_mtx(struct lock_object *lock, uintptr_t how);
+static int trylock_spin(struct lock_object *lock, uintptr_t how);
#ifdef KDTRACE_HOOKS
static int owner_mtx(const struct lock_object *lock,
struct thread **owner);
@@ -118,6 +120,7 @@
.lc_ddb_show = db_show_mtx,
#endif
.lc_lock = lock_mtx,
+ .lc_trylock = trylock_mtx,
.lc_unlock = unlock_mtx,
#ifdef KDTRACE_HOOKS
.lc_owner = owner_mtx,
@@ -131,6 +134,7 @@
.lc_ddb_show = db_show_mtx,
#endif
.lc_lock = lock_spin,
+ .lc_trylock = trylock_spin,
.lc_unlock = unlock_spin,
#ifdef KDTRACE_HOOKS
.lc_owner = owner_mtx,
@@ -216,6 +220,20 @@
mtx_lock_spin((struct mtx *)lock);
}
+static int
+trylock_mtx(struct lock_object *lock, uintptr_t how)
+{
+
+ return (mtx_trylock((struct mtx *)lock));
+}
+
+static int
+trylock_spin(struct lock_object *lock, uintptr_t how)
+{
+
+ return (mtx_trylock_spin((struct mtx *)lock));
+}
+
static uintptr_t
unlock_mtx(struct lock_object *lock)
{
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -72,6 +72,7 @@
#endif
static void assert_rw(const struct lock_object *lock, int what);
static void lock_rw(struct lock_object *lock, uintptr_t how);
+static int trylock_rw(struct lock_object *lock, uintptr_t how);
#ifdef KDTRACE_HOOKS
static int owner_rw(const struct lock_object *lock, struct thread **owner);
#endif
@@ -85,6 +86,7 @@
.lc_ddb_show = db_show_rwlock,
#endif
.lc_lock = lock_rw,
+ .lc_trylock = trylock_rw,
.lc_unlock = unlock_rw,
#ifdef KDTRACE_HOOKS
.lc_owner = owner_rw,
@@ -176,6 +178,18 @@
rw_wlock(rw);
}
+static int
+trylock_rw(struct lock_object *lock, uintptr_t how)
+{
+ struct rwlock *rw;
+
+ rw = (struct rwlock *)lock;
+ if (how)
+ return (rw_try_rlock(rw));
+ else
+ return (rw_try_wlock(rw));
+}
+
static uintptr_t
unlock_rw(struct lock_object *lock)
{
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -66,6 +66,7 @@
int (*lc_owner)(const struct lock_object *lock,
struct thread **owner);
uintptr_t (*lc_unlock)(struct lock_object *lock);
+ int (*lc_trylock)(struct lock_object *lock, uintptr_t how);
};
#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 3:28 PM (12 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14515723
Default Alt Text
D45745.diff (2 KB)

Event Timeline