ck_spinlock: Add ck_spinlock_*_locked.

This class of functions detects whether or not the
lock is currently acquired.
ck_pring
Samy Al Bahra 13 years ago
parent e8a96f4fb8
commit 0231b68a8b

@ -177,6 +177,13 @@ ck_spinlock_fas_trylock(struct ck_spinlock_fas *lock)
return (!value);
}
CK_CC_INLINE static bool
ck_spinlock_fas_locked(struct ck_spinlock_fas *lock)
{
return ck_pr_load_uint(&lock->value);
}
CK_CC_INLINE static void
ck_spinlock_fas_lock(struct ck_spinlock_fas *lock)
{
@ -239,6 +246,13 @@ ck_spinlock_cas_trylock(struct ck_spinlock_cas *lock)
return (!value);
}
CK_CC_INLINE static bool
ck_spinlock_cas_locked(struct ck_spinlock_cas *lock)
{
return ck_pr_load_uint(&lock->value);
}
CK_CC_INLINE static void
ck_spinlock_cas_lock(struct ck_spinlock_cas *lock)
{
@ -297,6 +311,13 @@ ck_spinlock_dec_trylock(struct ck_spinlock_dec *lock)
return (value == 1);
}
CK_CC_INLINE static bool
ck_spinlock_dec_locked(struct ck_spinlock_dec *lock)
{
return ck_pr_load_uint(&lock->value) != 1;
}
CK_CC_INLINE static void
ck_spinlock_dec_lock(struct ck_spinlock_dec *lock)
{
@ -470,6 +491,13 @@ ck_spinlock_mcs_trylock(struct ck_spinlock_mcs **queue, struct ck_spinlock_mcs *
return ck_pr_cas_ptr(queue, NULL, node);
}
CK_CC_INLINE static bool
ck_spinlock_mcs_locked(struct ck_spinlock_mcs **queue)
{
return ck_pr_load_ptr(queue) != NULL;
}
CK_CC_INLINE static void
ck_spinlock_mcs_lock(struct ck_spinlock_mcs **queue, struct ck_spinlock_mcs *node)
{

Loading…
Cancel
Save