MCPcopy Create free account
hub / github.com/F-Stack/f-stack / do_sem_wake

Function do_sem_wake

freebsd/kern/kern_umtx.c:3231–3265  ·  view source on GitHub ↗

* Signal a userland semaphore. */

Source from the content-addressed store, hash-verified

3229 * Signal a userland semaphore.
3230 */
3231static int
3232do_sem_wake(struct thread *td, struct _usem *sem)
3233{
3234 struct umtx_key key;
3235 int error, cnt;
3236 uint32_t flags;
3237
3238 error = fueword32(&sem->_flags, &flags);
3239 if (error == -1)
3240 return (EFAULT);
3241 if ((error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), &key)) != 0)
3242 return (error);
3243 umtxq_lock(&key);
3244 umtxq_busy(&key);
3245 cnt = umtxq_count(&key);
3246 if (cnt > 0) {
3247 /*
3248 * Check if count is greater than 0, this means the memory is
3249 * still being referenced by user code, so we can safely
3250 * update _has_waiters flag.
3251 */
3252 if (cnt == 1) {
3253 umtxq_unlock(&key);
3254 error = suword32(&sem->_has_waiters, 0);
3255 umtxq_lock(&key);
3256 if (error == -1)
3257 error = EFAULT;
3258 }
3259 umtxq_signal(&key, 1);
3260 }
3261 umtxq_unbusy(&key);
3262 umtxq_unlock(&key);
3263 umtx_key_release(&key);
3264 return (error);
3265}
3266#endif
3267
3268static int

Callers 1

__umtx_op_sem_wakeFunction · 0.85

Calls 9

fueword32Function · 0.85
umtx_key_getFunction · 0.85
umtxq_lockFunction · 0.85
umtxq_busyFunction · 0.85
umtxq_countFunction · 0.85
umtxq_unlockFunction · 0.85
suword32Function · 0.85
umtxq_unbusyFunction · 0.85
umtx_key_releaseFunction · 0.85

Tested by

no test coverage detected