Lines Matching defs:lock

28  * Machine independent bits of reader/writer lock implementation.
43 #include <sys/lock.h>
59 PMC_SOFT_DECLARE( , , lock, failed);
70 static void db_show_rwlock(struct lock_object *lock);
72 static void assert_rw(struct lock_object *lock, int what);
73 static void lock_rw(struct lock_object *lock, int how);
75 static int owner_rw(struct lock_object *lock, struct thread **owner);
77 static int unlock_rw(struct lock_object *lock);
94 * Return a pointer to the owning thread if the lock is write-locked or
95 * NULL if the lock is unlocked or read-locked.
108 * Return true if curthread helds the lock.
113 * Return a pointer to the owning thread for this lock who should receive
114 * any priority lent by threads that block on this lock. Currently this
124 assert_rw(struct lock_object *lock, int what)
127 rw_assert((struct rwlock *)lock, what);
131 lock_rw(struct lock_object *lock, int how)
135 rw = (struct rwlock *)lock;
143 unlock_rw(struct lock_object *lock)
147 rw = (struct rwlock *)lock;
160 owner_rw(struct lock_object *lock, struct thread **owner)
162 struct rwlock *rw = (struct rwlock *)lock;
203 KASSERT(rw->rw_lock == RW_UNLOCKED, ("rw lock %p not unlocked", rw));
204 KASSERT(rw->rw_recurse == 0, ("rw lock %p still recursed", rw));
300 * Determines whether a new reader can acquire a lock. Succeeds if the
301 * reader already owns a read lock and the lock is locked for read to
302 * prevent deadlock from reader recursion. Also succeeds if the lock
350 * lock, then try to bump up the count of read locks. Note
353 * read lock, then rw_lock must have changed, so restart
355 * completely unlocked rwlock since such a lock is encoded
356 * as a read lock with no waiters.
362 * if the lock has been unlocked and write waiters
377 PMC_SOFT_CALL( , , lock, failed);
385 * the owner stops running or the state of the lock
419 * has a write lock or there are write waiters present,
420 * acquire the turnstile lock so we can begin the process
426 * The lock might have been released while we spun, so
437 * The current lock owner might have started executing
438 * on another CPU (or the lock could have changed
440 * chain lock. If so, drop the turnstile lock and try
453 * The lock is held in write mode or it already has waiters.
461 * lock and restart the loop.
475 * We were unable to acquire the lock and the read waiters
570 * See if there is more than one read lock held. If so,
587 * If there aren't any waiters for a write lock, then try
604 * last reader, so grab the turnstile lock.
611 * Try to drop our lock leaving the lock in a unlocked
614 * If you wanted to do explicit lock handoff you'd have to
617 * priority thread blocks on the write lock before the
619 * "steal" the lock. For now it's a lot simpler to just
623 * acquired a read lock, so drop the turnstile lock and
642 * Ok. The lock is released and all that's left is to
643 * wake up the waiters. Note that the lock might not be
645 * block again if they run before the new lock holder(s)
646 * release the lock.
659 * This function is called when we are unable to obtain a write lock on the
661 * read or write lock.
697 CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__,
705 PMC_SOFT_CALL( , , lock, failed);
711 * If the lock is write locked and the owner is
713 * running or the state of the lock changes.
756 * The current lock owner might have started executing
757 * on another CPU (or the lock could have changed
759 * chain lock. If so, drop the turnstile lock and try
772 * If the lock was released, without maintain any pending
774 * If a pending waiters queue is present, claim the lock
806 * We were unable to acquire the lock and the write waiters
842 * This function is called if the first try at releasing a write lock failed.
844 * least one thread is waiting on this lock.
884 * new writer comes in before a reader it will claim the lock up
887 * of waiters or doing some complicated lock handoff gymnastics.
907 * Attempt to do a non-blocking upgrade from a read lock to a write
908 * lock. This will only succeed if this thread holds a single read
909 * lock. Returns true if the upgrade succeeded and false otherwise.
927 * are any write waiters, then we will have to lock the
946 * Ok, we think we have waiters, so lock the turnstile.
957 * If we obtain the lock with the flags set, then claim
982 * Downgrade a write lock into a single read lock.
999 panic("downgrade of a recursed lock");
1007 * lock the turnstile and "disown" the lock.
1014 * Ok, we think we have waiters, so lock the turnstile so we can
1024 * Downgrade from a write lock while preserving waiters flag
1034 * won't be able to acquire the lock anyway.
1075 * If some other thread has a write lock or we have one
1076 * and are asserting a read lock, fail. Also, if no one
1077 * has a lock at all, fail.
1117 * If we hold a write lock fail. We can't reliably check
1118 * to see if we hold a read lock or not.
1126 panic("Unknown rw lock assertion: %d @ %s:%d", what, file,
1134 db_show_rwlock(struct lock_object *lock)
1139 rw = (struct rwlock *)lock;