kernels/linux-2.4.0/include/asm-mips64/semaphore.h
/*
 * Releasing the writer is easy -- just release it and wake up any sleepers.
 */
Releasing the writer is easy -- just release it and wake up any sleepers.
Releasing the writer is easy -- just release it and wake up any sleepers .
static inline void up_write(struct rw_semaphore *sem)
{
	int count;
#if WAITQUEUE_DEBUG
	CHECK_MAGIC(sem->__magic);
	if (sem->granted & 3)
		BUG();
	if (atomic_read(&sem->readers))
		BUG();
	if (atomic_read(&sem->writers) != 1)
		BUG();
	atomic_dec(&sem->writers);
#endif
	mb();
	count = atomic_add_return(RW_LOCK_BIAS, &sem->count);
	if (count - RW_LOCK_BIAS < 0 && count >= 0) {
		__rwsem_wake(sem, count);
	}
}
static inline void up_write ( struct rw_semaphore * sem ) { int count ; #if WAITQUEUE_DEBUG CHECK_MAGIC ( sem -> __magic ) ; if ( sem -> granted & 3 ) BUG ( ) ; if ( atomic_read ( & sem -> readers ) ) BUG ( ) ; if ( atomic_read ( & sem -> writers ) != 1 ) BUG ( ) ; atomic_dec ( & sem -> writers ) ; #endif mb ( ) ; count = atomic_add_return ( RW_LOCK_BIAS , & sem -> count ) ; if ( count - RW_LOCK_BIAS < 0 && count >= 0 ) { __rwsem_wake ( sem , count ) ; } }
Releasing the writer is easy -- just release it and wake up any sleepers.
Releasing the writer is easy -- just release it and wake up any sleepers .
/* Only do the wake if we're no longer negative.  */