patch-2.4.4 linux/arch/alpha/kernel/semaphore.c
Next file: linux/arch/alpha/mm/init.c
Previous file: linux/arch/alpha/kernel/alpha_ksyms.c
Back to the patch index
Back to the overall index
- Lines: 186
- Date:
Tue Apr 17 17:19:24 2001
- Orig file:
v2.4.3/linux/arch/alpha/kernel/semaphore.c
- Orig date:
Sun Nov 12 19:31:11 2000
diff -u --recursive --new-file v2.4.3/linux/arch/alpha/kernel/semaphore.c linux/arch/alpha/kernel/semaphore.c
@@ -263,185 +263,3 @@
#endif
__up(sem);
}
-
-
-/*
- * RW Semaphores
- */
-
-void
-__down_read_failed(struct rw_semaphore *sem, int count)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- retry_down:
- if (count < 0) {
- /* Waiting on multiple readers and/or writers. */
-
- /* Undo the acquisition we started in down_read. */
- atomic_inc(&sem->count);
-
- current->state = TASK_UNINTERRUPTIBLE;
- wmb();
- add_wait_queue(&sem->wait, &wait);
- mb();
- while (atomic_read(&sem->count) < 0) {
- schedule();
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- }
-
- remove_wait_queue(&sem->wait, &wait);
- current->state = TASK_RUNNING;
-
- mb();
- count = atomic_dec_return(&sem->count);
- if (count <= 0)
- goto retry_down;
- } else {
- /* Waiting on exactly one writer. */
-
- current->state = TASK_UNINTERRUPTIBLE;
- wmb();
- add_wait_queue(&sem->wait, &wait);
- mb();
-
- while (!test_and_clear_bit(0, &sem->granted)) {
- schedule();
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- }
-
- remove_wait_queue(&sem->wait, &wait);
- current->state = TASK_RUNNING;
- }
-}
-
-void
-__down_write_failed(struct rw_semaphore *sem, int count)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- retry_down:
- if (count + RW_LOCK_BIAS < 0) {
- /* Waiting on multiple readers and/or writers. */
-
- /* Undo the acquisition we started in down_write. */
- atomic_add(RW_LOCK_BIAS, &sem->count);
-
- current->state = TASK_UNINTERRUPTIBLE;
- wmb();
- add_wait_queue_exclusive(&sem->wait, &wait);
- mb();
-
- while (atomic_read(&sem->count) + RW_LOCK_BIAS < 0) {
- schedule();
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- }
-
- remove_wait_queue(&sem->wait, &wait);
- current->state = TASK_RUNNING;
-
- count = atomic_sub_return(RW_LOCK_BIAS, &sem->count);
- if (count != 0)
- goto retry_down;
- } else {
- /* Waiting on exactly one writer. */
-
- current->state = TASK_UNINTERRUPTIBLE;
- wmb();
- add_wait_queue_exclusive(&sem->wait, &wait);
- mb();
-
- while (!test_and_clear_bit(1, &sem->granted)) {
- schedule();
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- }
-
- remove_wait_queue(&sem->write_bias_wait, &wait);
- current->state = TASK_RUNNING;
-
- /* If the lock is currently unbiased, awaken the sleepers.
- FIXME: This wakes up the readers early in a bit of a
- stampede -> bad! */
- count = atomic_read(&sem->count);
- if (__builtin_expect(count >= 0, 0))
- wake_up(&sem->wait);
- }
-}
-
-void
-__rwsem_wake(struct rw_semaphore *sem, int readers)
-{
- if (readers) {
- if (test_and_set_bit(0, &sem->granted))
- BUG();
- wake_up(&sem->wait);
- } else {
- if (test_and_set_bit(1, &sem->granted))
- BUG();
- wake_up(&sem->write_bias_wait);
- }
-}
-
-void
-down_read(struct rw_semaphore *sem)
-{
-#if WAITQUEUE_DEBUG
- CHECK_MAGIC(sem->__magic);
-#endif
- __down_read(sem);
-#if WAITQUEUE_DEBUG
- if (sem->granted & 2)
- BUG();
- if (atomic_read(&sem->writers))
- BUG();
- atomic_inc(&sem->readers);
-#endif
-}
-
-void
-down_write(struct rw_semaphore *sem)
-{
-#if WAITQUEUE_DEBUG
- CHECK_MAGIC(sem->__magic);
-#endif
- __down_write(sem);
-#if WAITQUEUE_DEBUG
- if (sem->granted & 3)
- BUG();
- if (atomic_read(&sem->writers))
- BUG();
- if (atomic_read(&sem->readers))
- BUG();
- atomic_inc(&sem->writers);
-#endif
-}
-
-void
-up_read(struct rw_semaphore *sem)
-{
-#if WAITQUEUE_DEBUG
- CHECK_MAGIC(sem->__magic);
- if (sem->granted & 2)
- BUG();
- if (atomic_read(&sem->writers))
- BUG();
- atomic_dec(&sem->readers);
-#endif
- __up_read(sem);
-}
-
-void
-up_write(struct rw_semaphore *sem)
-{
-#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
- __up_write(sem);
-}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)