• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.5.8/xnu-1228.15.4/osfmk/kern/

Lines Matching defs:semaphore

36  *	Contains RT distributed semaphore synchronization services.
42 #include <mach/semaphore.h>
101 semaphore_t semaphore,
122 * Initialize the semaphore mechanisms.
123 * Right now, we only need to initialize the semaphore zone.
128 semaphore_zone = zinit(sizeof(struct semaphore),
129 semaphore_max * sizeof(struct semaphore),
130 sizeof(struct semaphore),
137 * Creates a semaphore.
138 * The port representing the semaphore is returned as a parameter.
168 * Create and initialize the semaphore port
172 /* This will deallocate the semaphore */
181 * Associate the new semaphore with the task by adding
182 * the new semaphore to the task's semaphore list.
184 * Associate the task with the new semaphore by having the
202 * Destroys a semaphore. This call will only succeed if the
203 * specified task is the SAME task name specified at the semaphore's
206 * All threads currently blocked on the semaphore are awoken. These
212 semaphore_t semaphore)
218 if (task == TASK_NULL || semaphore == SEMAPHORE_NULL)
222 * Disown semaphore
225 if (semaphore->owner != task) {
229 remqueue(&task->semaphore_list, (queue_entry_t) semaphore);
230 semaphore->owner = TASK_NULL;
235 semaphore_lock(semaphore);
238 * Deactivate semaphore
240 assert(semaphore->active);
241 semaphore->active = FALSE;
246 old_count = semaphore->count;
247 semaphore->count = 0;
250 wait_queue_wakeup64_all_locked(&semaphore->wait_queue,
255 semaphore_unlock(semaphore);
262 * Drop the semaphore reference, which in turn deallocates the
263 * semaphore structure if the reference count goes to zero.
265 ipc_port_dealloc_kernel(semaphore->port);
266 semaphore_dereference(semaphore);
273 * Signals the semaphore as direct.
279 semaphore_t semaphore,
287 semaphore_lock(semaphore);
289 if (!semaphore->active) {
290 semaphore_unlock(semaphore);
296 if (semaphore->count < 0) {
298 &semaphore->wait_queue,
304 semaphore_unlock(semaphore);
312 int old_count = semaphore->count;
315 semaphore->count = 0; /* always reset */
317 &semaphore->wait_queue,
323 semaphore->count++;
324 semaphore_unlock(semaphore);
331 if (semaphore->count < 0) {
333 &semaphore->wait_queue,
337 semaphore_unlock(semaphore);
341 semaphore->count = 0; /* all waiters gone */
345 semaphore->count++;
348 semaphore_unlock(semaphore);
356 * If the specified thread is blocked on the semaphore, it is
359 * and the semaphore is unchanged.
363 semaphore_t semaphore,
368 if (semaphore == SEMAPHORE_NULL)
371 ret = semaphore_signal_internal(semaphore,
388 semaphore_t semaphore;
395 * pre-post the semaphore.
404 kr = port_name_to_semaphore(sema_name, &semaphore);
406 kr = semaphore_signal_internal(semaphore,
409 semaphore_dereference(semaphore);
422 * Traditional (in-kernel client and MIG interface) semaphore
432 semaphore_t semaphore)
436 if (semaphore == SEMAPHORE_NULL)
439 kr = semaphore_signal_internal(semaphore,
464 semaphore_t semaphore;
467 kr = port_name_to_semaphore(sema_name, &semaphore);
469 kr = semaphore_signal_internal(semaphore,
472 semaphore_dereference(semaphore);
482 * Awakens ALL threads currently blocked on the semaphore.
483 * The semaphore count returns to zero.
487 semaphore_t semaphore)
491 if (semaphore == SEMAPHORE_NULL)
494 kr = semaphore_signal_internal(semaphore,
512 semaphore_t semaphore;
515 kr = port_name_to_semaphore(sema_name, &semaphore);
517 kr = semaphore_signal_internal(semaphore,
520 semaphore_dereference(semaphore);
530 * Generate the return code after a semaphore wait/block. It
581 * Decrements the semaphore count by one. If the count is
587 * A reference is held on the signal semaphore.
654 * lock the signal semaphore reference we got and signal it.
666 * Uh!Oh! The semaphore we were to signal died.
669 * that the semaphore we were posting is gating
671 * semaphore we are waiting on). People will
672 * discover the other dead semaphore soon enough.
689 * return now that we have signalled the signal semaphore.
697 * appropriate semaphore continuation. Thiswill gather the
698 * semaphore results, release references on the semaphore(s),
721 * in-kernel clients to wait on a semaphore.
725 semaphore_t semaphore)
728 if (semaphore == SEMAPHORE_NULL)
731 return(semaphore_wait_internal(semaphore,
740 * Trap version of semaphore wait. Called on behalf of user-level
758 semaphore_t semaphore;
761 kr = port_name_to_semaphore(name, &semaphore);
763 kr = semaphore_wait_internal(semaphore,
767 semaphore_dereference(semaphore);
776 * in-kernel clients to wait on a semaphore with a timeout.
782 semaphore_t semaphore,
785 if (semaphore == SEMAPHORE_NULL)
791 return (semaphore_wait_internal(semaphore,
826 semaphore_t semaphore;
835 kr = port_name_to_semaphore(name, &semaphore);
837 kr = semaphore_wait_internal(semaphore,
841 semaphore_dereference(semaphore);
849 * Atomically register a wait on a semaphore and THEN signal
871 * Atomically register a wait on a semaphore and THEN signal
910 * Atomically register a wait on a semaphore and THEN signal
937 * Atomically register a timed wait on a semaphore and THEN signal
984 * Take out a reference on a semaphore. This keeps the data structure
985 * in existence (but the semaphore may be deactivated).
989 semaphore_t semaphore)
994 semaphore_lock(semaphore);
996 semaphore->ref_count++;
998 semaphore_unlock(semaphore);
1005 * Release a reference on a semaphore. If this is the last reference,
1006 * the semaphore data structure is deallocated.
1010 semaphore_t semaphore)
1015 if (semaphore != NULL) {
1017 semaphore_lock(semaphore);
1019 ref_count = --(semaphore->ref_count);
1021 semaphore_unlock(semaphore);
1025 assert(wait_queue_empty(&semaphore->wait_queue));
1026 zfree(semaphore_zone, semaphore);