• Home
  • Raw
  • Download

Lines Matching full:count

12  *   1) Upper half of semaphore count is a wait count (differs from rwsem
90 atomic_long_set(&sem->count, LDSEM_UNLOCKED); in __init_ldsem()
101 long adjust, count; in __ldsem_wake_readers() local
105 * Note the 'active part' of the count is incremented by in __ldsem_wake_readers()
109 count = atomic_long_add_return(adjust, &sem->count); in __ldsem_wake_readers()
111 if (count > 0) in __ldsem_wake_readers()
113 if (atomic_long_try_cmpxchg(&sem->count, &count, count - adjust)) in __ldsem_wake_readers()
130 * Only wake this writer if the active part of the count can be in writer_trylock()
133 long count = atomic_long_add_return(LDSEM_ACTIVE_BIAS, &sem->count); in writer_trylock() local
135 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS) in writer_trylock()
137 if (atomic_long_try_cmpxchg(&sem->count, &count, count - LDSEM_ACTIVE_BIAS)) in writer_trylock()
153 * - the 'active part' of count (&0x0000ffff) reached 0 (but may have changed)
154 * - the 'waiting part' of count (&0xffff0000) is -ve (and will still be so)
179 down_read_failed(struct ld_semaphore *sem, long count, long timeout) in down_read_failed() argument
188 * Try to reverse the lock attempt but if the count has changed in down_read_failed()
193 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust)) { in down_read_failed()
194 count += adjust; in down_read_failed()
197 if (count > 0) { in down_read_failed()
210 if ((count & LDSEM_ACTIVE_MASK) == 0) in down_read_failed()
236 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); in down_read_failed()
252 down_write_failed(struct ld_semaphore *sem, long count, long timeout) in down_write_failed() argument
262 * Try to reverse the lock attempt but if the count has changed in down_write_failed()
267 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust)) in down_write_failed()
269 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS) { in down_write_failed()
293 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); in down_write_failed()
320 long count; in __ldsem_down_read_nested() local
324 count = atomic_long_add_return(LDSEM_READ_BIAS, &sem->count); in __ldsem_down_read_nested()
325 if (count <= 0) { in __ldsem_down_read_nested()
327 if (!down_read_failed(sem, count, timeout)) { in __ldsem_down_read_nested()
339 long count; in __ldsem_down_write_nested() local
343 count = atomic_long_add_return(LDSEM_WRITE_BIAS, &sem->count); in __ldsem_down_write_nested()
344 if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) { in __ldsem_down_write_nested()
346 if (!down_write_failed(sem, count, timeout)) { in __ldsem_down_write_nested()
370 long count = atomic_long_read(&sem->count); in ldsem_down_read_trylock() local
372 while (count >= 0) { in ldsem_down_read_trylock()
373 if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_READ_BIAS)) { in ldsem_down_read_trylock()
396 long count = atomic_long_read(&sem->count); in ldsem_down_write_trylock() local
398 while ((count & LDSEM_ACTIVE_MASK) == 0) { in ldsem_down_write_trylock()
399 if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_WRITE_BIAS)) { in ldsem_down_write_trylock()
413 long count; in ldsem_up_read() local
417 count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count); in ldsem_up_read()
418 if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0) in ldsem_up_read()
427 long count; in ldsem_up_write() local
431 count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count); in ldsem_up_write()
432 if (count < 0) in ldsem_up_write()