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

Function do_unlock_pp

freebsd/kern/kern_umtx.c:2295–2376  ·  view source on GitHub ↗

* Unlock a PP mutex. */

Source from the content-addressed store, hash-verified

2293 * Unlock a PP mutex.
2294 */
2295static int
2296do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags, bool rb)
2297{
2298 struct umtx_key key;
2299 struct umtx_q *uq, *uq2;
2300 struct umtx_pi *pi;
2301 uint32_t id, owner, rceiling;
2302 int error, pri, new_inherited_pri, su;
2303
2304 id = td->td_tid;
2305 uq = td->td_umtxq;
2306 su = (priv_check(td, PRIV_SCHED_RTPRIO) == 0);
2307
2308 /*
2309 * Make sure we own this mtx.
2310 */
2311 error = fueword32(&m->m_owner, &owner);
2312 if (error == -1)
2313 return (EFAULT);
2314
2315 if ((owner & ~UMUTEX_CONTESTED) != id)
2316 return (EPERM);
2317
2318 error = copyin(&m->m_ceilings[1], &rceiling, sizeof(uint32_t));
2319 if (error != 0)
2320 return (error);
2321
2322 if (rceiling == -1)
2323 new_inherited_pri = PRI_MAX;
2324 else {
2325 rceiling = RTP_PRIO_MAX - rceiling;
2326 if (rceiling > RTP_PRIO_MAX)
2327 return (EINVAL);
2328 new_inherited_pri = PRI_MIN_REALTIME + rceiling;
2329 }
2330
2331 if ((error = umtx_key_get(m, (flags & UMUTEX_ROBUST) != 0 ?
2332 TYPE_PP_ROBUST_UMUTEX : TYPE_PP_UMUTEX, GET_SHARE(flags),
2333 &key)) != 0)
2334 return (error);
2335 umtxq_lock(&key);
2336 umtxq_busy(&key);
2337 umtxq_unlock(&key);
2338 /*
2339 * For priority protected mutex, always set unlocked state
2340 * to UMUTEX_CONTESTED, so that userland always enters kernel
2341 * to lock the mutex, it is necessary because thread priority
2342 * has to be adjusted for such mutex.
2343 */
2344 error = suword32(&m->m_owner, umtx_unlock_val(flags, rb) |
2345 UMUTEX_CONTESTED);
2346
2347 umtxq_lock(&key);
2348 if (error == 0)
2349 umtxq_signal(&key, 1);
2350 umtxq_unbusy(&key);
2351 umtxq_unlock(&key);
2352

Callers 1

do_unlock_umutexFunction · 0.85

Calls 14

fueword32Function · 0.85
umtx_key_getFunction · 0.85
umtxq_lockFunction · 0.85
umtxq_busyFunction · 0.85
umtxq_unlockFunction · 0.85
suword32Function · 0.85
umtx_unlock_valFunction · 0.85
umtxq_unbusyFunction · 0.85
umtx_key_releaseFunction · 0.85
priv_checkFunction · 0.70
mtx_lockFunction · 0.70
sched_lend_user_prioFunction · 0.70

Tested by

no test coverage detected