index
:
litmus-rt.git
archive/unc-master-3.0
archived-2013.1
archived-private-master
archived-semi-part
demo
ecrts-pgm-final
ecrts14-pgm-final
gpusync-rtss12
gpusync/staging
linux-tip
litmus2008-patch-series
master
pgm
prop/litmus-signals
prop/robust-tie-break
staging
test
tracing-devel
v2.6.34-with-arm-patches
v2015.1
wip-2011.2-bbb
wip-2011.2-bbb-trace
wip-2012.3-gpu
wip-2012.3-gpu-preport
wip-2012.3-gpu-rtss13
wip-2012.3-gpu-sobliv-budget-w-kshark
wip-aedzl-final
wip-aedzl-revised
wip-arbit-deadline
wip-aux-tasks
wip-bbb
wip-bbb-prio-don
wip-better-break
wip-binary-heap
wip-budget
wip-color
wip-color-jlh
wip-d10-hz1000
wip-default-clustering
wip-dissipation-jerickso
wip-dissipation2-jerickso
wip-ecrts14-pgm
wip-edf-hsb
wip-edf-os
wip-edf-tie-break
wip-edzl-critique
wip-edzl-final
wip-edzl-revised
wip-events
wip-extra-debug
wip-fix-switch-jerickso
wip-fix3
wip-fmlp-dequeue
wip-ft-irq-flag
wip-gpu-cleanup
wip-gpu-interrupts
wip-gpu-rtas12
wip-gpu-rtss12
wip-gpu-rtss12-srp
wip-gpusync-merge
wip-ikglp
wip-k-fmlp
wip-kernel-coloring
wip-kernthreads
<
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/atomic.h>
/*
* This is an implementation of the notion of "decrement a
* reference count, and return locked if it decremented to zero".
*
* NOTE NOTE NOTE! This is _not_ equivalent to
*
* if (atomic_dec_and_test(&atomic)) {
* spin_lock(&lock);
* return 1;
* }
* return 0;
*
* because the spin-lock and the decrement must be
* "atomic".
*/
int
_atomic_dec_and_lock
(
atomic_t
*
atomic
,
spinlock_t
*
lock
)
{
/* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */
if
(
atomic_add_unless
(
atomic
, -
1
,
1
))
return
0
;
/* Otherwise do it the slow way */
spin_lock
(
lock
);
if
(
atomic_dec_and_test
(
atomic
))
return
1
;
spin_unlock
(
lock
);
return
0
;
}
EXPORT_SYMBOL
(
_atomic_dec_and_lock
);