aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_umtx.c26
-rw-r--r--sys/sys/umtxvar.h4
2 files changed, 30 insertions, 0 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index ae80554cbbb8..d869d5870000 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -559,6 +559,32 @@ umtxq_count_pi(struct umtx_key *key, struct umtx_q **first)
}
/*
+ * 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
index 68f261fe6abf..de1b649ed8d7 100644
--- a/sys/sys/umtxvar.h
+++ b/sys/sys/umtxvar.h
@@ -120,6 +120,9 @@ struct umtx_q {
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 @@ void umtxq_free(struct umtx_q *);
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 *);