diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -558,6 +558,32 @@ return (0); } +/* + * Wake up threads waiting on an userland object by a bit mask. + */ +int +umtxq_signal_mask(struct umtx_key *key, int n_wake, u_int bitset) +{ + struct umtxq_queue *uh; + struct umtx_q *uq, *uq_temp; + int ret; + + ret = 0; + UMTXQ_LOCKED_ASSERT(umtxq_getchain(key)); + uh = umtxq_queue_lookup(key, UMTX_SHARED_QUEUE); + if (uh == NULL) + return (0); + TAILQ_FOREACH_SAFE(uq, &uh->head, uq_link, uq_temp) { + if ((uq->uq_bitset & bitset) == 0) + continue; + umtxq_remove_queue(uq, UMTX_SHARED_QUEUE); + wakeup_one(uq); + if (++ret >= n_wake) + break; + } + return (ret); +} + /* * Wake up threads waiting on an userland object. */ diff --git a/sys/sys/umtxvar.h b/sys/sys/umtxvar.h --- a/sys/sys/umtxvar.h +++ b/sys/sys/umtxvar.h @@ -120,6 +120,9 @@ int uq_flags; #define UQF_UMTXQ 0x0001 + /* Futex bitset mask */ + u_int uq_bitset; + /* The thread waits on. */ struct thread *uq_thread; @@ -207,6 +210,7 @@ struct umtxq_chain *umtxq_getchain(struct umtx_key *); void umtxq_insert_queue(struct umtx_q *, int); void umtxq_remove_queue(struct umtx_q *, int); +int umtxq_signal_mask(struct umtx_key *, int, u_int); int umtxq_sleep(struct umtx_q *, const char *, struct umtx_abs_timeout *); void umtxq_unbusy(struct umtx_key *);