函数源码 |
Source File:lib\lockref.c |
Create Date:2022-07-27 07:16:12 |
首页 | Copyright©Brick |
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /** * lockref_get_or_lock - Increments count unless the count is 0 or dead * @lockref: pointer to lockref structure * Return: 1 if count updated successfully or 0 if count was zero * and we got the lock instead. */ int lockref_get_or_lock( struct lockref *lockref) { CMPXCHG_LOOP( new .count++; if (old.count <= 0) break ; , return 1; ); spin_lock(&lockref->lock); if (lockref->count <= 0) return 0; lockref->count++; spin_unlock(&lockref->lock); return 1; } |