Add rms_try_rlock and rms_wowned.
This commit is contained in:
parent
cedad2916e
commit
1a78ac2416
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357320
@ -934,6 +934,30 @@ rms_rlock(struct rmslock *rms)
|
||||
critical_exit();
|
||||
}
|
||||
|
||||
int
|
||||
rms_try_rlock(struct rmslock *rms)
|
||||
{
|
||||
int *influx;
|
||||
|
||||
critical_enter();
|
||||
influx = zpcpu_get(rms->readers_influx);
|
||||
__compiler_membar();
|
||||
*influx = 1;
|
||||
__compiler_membar();
|
||||
if (__predict_false(rms->writers > 0)) {
|
||||
__compiler_membar();
|
||||
*influx = 0;
|
||||
critical_exit();
|
||||
return (0);
|
||||
}
|
||||
__compiler_membar();
|
||||
(*zpcpu_get(rms->readers_pcpu))++;
|
||||
__compiler_membar();
|
||||
*influx = 0;
|
||||
critical_exit();
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void __noinline
|
||||
rms_runlock_fallback(struct rmslock *rms)
|
||||
{
|
||||
|
@ -136,9 +136,21 @@ struct rm_args {
|
||||
void rms_init(struct rmslock *rms, const char *name);
|
||||
void rms_destroy(struct rmslock *rms);
|
||||
void rms_rlock(struct rmslock *rms);
|
||||
int rms_try_rlock(struct rmslock *rms);
|
||||
void rms_runlock(struct rmslock *rms);
|
||||
void rms_wlock(struct rmslock *rms);
|
||||
void rms_wunlock(struct rmslock *rms);
|
||||
|
||||
/*
|
||||
* Writers are not explicitly tracked, thus until that changes the best we can
|
||||
* do is indicate the lock is taken for writing by *someone*.
|
||||
*/
|
||||
static inline int
|
||||
rms_wowned(struct rmslock *rms)
|
||||
{
|
||||
|
||||
return (rms->writers > 0);
|
||||
}
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_SYS_RMLOCK_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user