Lines Matching defs:count
12 * 1) Upper half of semaphore count is a wait count (differs from rwsem
67 atomic_long_set(&sem->count, LDSEM_UNLOCKED);
78 long adjust, count;
82 * Note the 'active part' of the count is incremented by
86 count = atomic_long_add_return(adjust, &sem->count);
88 if (count > 0)
90 if (atomic_long_try_cmpxchg(&sem->count, &count, count - adjust))
107 * Only wake this writer if the active part of the count can be
110 long count = atomic_long_add_return(LDSEM_ACTIVE_BIAS, &sem->count);
112 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS)
114 if (atomic_long_try_cmpxchg(&sem->count, &count, count - LDSEM_ACTIVE_BIAS))
130 * - the 'active part' of count (&0x0000ffff) reached 0 (but may have changed)
131 * - the 'waiting part' of count (&0xffff0000) is -ve (and will still be so)
156 down_read_failed(struct ld_semaphore *sem, long count, long timeout)
165 * Try to reverse the lock attempt but if the count has changed
170 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust)) {
171 count += adjust;
174 if (count > 0) {
187 if ((count & LDSEM_ACTIVE_MASK) == 0)
213 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count);
230 down_write_failed(struct ld_semaphore *sem, long count, long timeout)
240 * Try to reverse the lock attempt but if the count has changed
245 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust))
247 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS) {
271 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count);
298 long count;
302 count = atomic_long_add_return(LDSEM_READ_BIAS, &sem->count);
303 if (count <= 0) {
305 if (!down_read_failed(sem, count, timeout)) {
317 long count;
321 count = atomic_long_add_return(LDSEM_WRITE_BIAS, &sem->count);
322 if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) {
324 if (!down_write_failed(sem, count, timeout)) {
348 long count = atomic_long_read(&sem->count);
350 while (count >= 0) {
351 if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_READ_BIAS)) {
374 long count;
378 count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count);
379 if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0)
388 long count;
392 count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count);
393 if (count < 0)