* Lightweight entry points for common operations. * * Functionality is similar to sx locks, in that none of the additional lockmgr * features are supported. To be clear, these are NOT supported: * 1. shared locking disablement * 2. returning with an error after sleep * 3. unlocking the interlock * * If in doubt, use lockmgr_lock_flags. */
| 1221 | * If in doubt, use lockmgr_lock_flags. |
| 1222 | */ |
| 1223 | int |
| 1224 | lockmgr_slock(struct lock *lk, u_int flags, const char *file, int line) |
| 1225 | { |
| 1226 | uintptr_t x; |
| 1227 | |
| 1228 | MPASS((flags & LK_TYPE_MASK) == LK_SHARED); |
| 1229 | MPASS((flags & LK_INTERLOCK) == 0); |
| 1230 | MPASS((lk->lock_object.lo_flags & LK_NOSHARE) == 0); |
| 1231 | |
| 1232 | if (LK_CAN_WITNESS(flags)) |
| 1233 | WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER, |
| 1234 | file, line, NULL); |
| 1235 | x = lockmgr_read_value(lk); |
| 1236 | if (__predict_true(lockmgr_slock_try(lk, &x, flags, true))) { |
| 1237 | lockmgr_note_shared_acquire(lk, 0, 0, file, line, flags); |
| 1238 | return (0); |
| 1239 | } |
| 1240 | |
| 1241 | return (lockmgr_slock_hard(lk, flags | LK_ADAPTIVE, NULL, file, line, NULL)); |
| 1242 | } |
| 1243 | |
| 1244 | int |
| 1245 | lockmgr_xlock(struct lock *lk, u_int flags, const char *file, int line) |
no test coverage detected