+convert_semaphore_to_port(semaphore_t semaphore)
+{
+ if (semaphore == SEMAPHORE_NULL) {
+ return IP_NULL;
+ }
+
+ /*
+ * make a send right and donate our reference for
+ * semaphore_notify if this is the first send right
+ */
+ if (!ipc_kobject_make_send_lazy_alloc_port(&semaphore->port,
+ (ipc_kobject_t) semaphore, IKOT_SEMAPHORE)) {
+ semaphore_dereference(semaphore);
+ }
+ return semaphore->port;
+}
+
+/*
+ * Routine: semaphore_notify
+ * Purpose:
+ * Called whenever the Mach port system detects no-senders
+ * on the semaphore port.
+ *
+ * When a send-right is first created, a no-senders
+ * notification is armed (and a semaphore reference is donated).
+ *
+ * A no-senders notification will be posted when no one else holds a
+ * send-right (reference) to the semaphore's port. This notification function
+ * will consume the semaphore reference donated to the extant collection of
+ * send-rights.
+ */
+void
+semaphore_notify(mach_msg_header_t *msg)