Lines Matching refs:lock_set
121 * Initialize the lock_set subsystem.
127 lck_grp_init(&lock_set_grp, "lock_set", &lock_set_grp_attr);
145 lock_set_t lock_set = LOCK_SET_NULL;
155 if ((VM_MAX_ADDRESS - sizeof(struct lock_set))/sizeof(struct ulock) < (unsigned)n_ulocks)
158 size = sizeof(struct lock_set) + (sizeof(struct ulock) * (n_ulocks-1));
159 lock_set = (lock_set_t) kalloc (size);
161 if (lock_set == LOCK_SET_NULL)
165 lock_set_lock_init(lock_set);
166 lock_set->n_ulocks = n_ulocks;
167 lock_set->ref_count = (task == kernel_task) ? 1 : 2; /* one for kernel, one for port */
172 lock_set->port = ipc_port_alloc_kernel();
173 if (lock_set->port == IP_NULL) {
174 kfree(lock_set, size);
178 ipc_kobject_set (lock_set->port,
179 (ipc_kobject_t) lock_set,
187 ulock = (ulock_t) &lock_set->ulock_list[x];
189 ulock->lock_set = lock_set;
198 lock_set_ownership_set(lock_set, task);
200 lock_set->active = TRUE;
201 *new_lock_set = lock_set;
218 lock_set_destroy (task_t task, lock_set_t lock_set)
223 if (task == TASK_NULL || lock_set == LOCK_SET_NULL)
226 if (lock_set->owner != task)
229 lock_set_lock(lock_set);
230 if (!lock_set->active) {
231 lock_set_unlock(lock_set);
238 lock_set->active = FALSE;
251 for (i = 0; i < lock_set->n_ulocks; i++) {
252 ulock = &lock_set->ulock_list[i];
282 lock_set_unlock(lock_set);
283 lock_set_ownership_clear(lock_set, task);
290 lock_set_dereference(lock_set);
296 lock_acquire (lock_set_t lock_set, int lock_id)
300 if (lock_set == LOCK_SET_NULL)
303 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
307 lock_set_lock(lock_set);
308 if (!lock_set->active) {
309 lock_set_unlock(lock_set);
313 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
315 lock_set_unlock(lock_set);
358 goto retry; /* probably a dead lock_set */
375 lock_release (lock_set_t lock_set, int lock_id)
379 if (lock_set == LOCK_SET_NULL)
382 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
385 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
391 lock_try (lock_set_t lock_set, int lock_id)
396 if (lock_set == LOCK_SET_NULL)
399 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
403 lock_set_lock(lock_set);
404 if (!lock_set->active) {
405 lock_set_unlock(lock_set);
409 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
411 lock_set_unlock(lock_set);
421 lock_set_unlock(lock_set);
443 lock_make_stable (lock_set_t lock_set, int lock_id)
448 if (lock_set == LOCK_SET_NULL)
451 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
455 lock_set_lock(lock_set);
456 if (!lock_set->active) {
457 lock_set_unlock(lock_set);
461 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
463 lock_set_unlock(lock_set);
488 lock_set_t lock_set;
490 lock_set = ulock->lock_set;
491 lock_set_lock(lock_set);
492 if (!lock_set->active) {
493 lock_set_unlock(lock_set);
498 lock_set_unlock(lock_set);
521 lock_set_t lock_set;
523 if ((lock_set = ulock->lock_set) == LOCK_SET_NULL)
526 lock_set_lock(lock_set);
527 if (!lock_set->active) {
528 lock_set_unlock(lock_set);
532 lock_set_unlock(lock_set);
586 lock_handoff (lock_set_t lock_set, int lock_id)
592 if (lock_set == LOCK_SET_NULL)
595 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
599 lock_set_lock(lock_set);
601 if (!lock_set->active) {
602 lock_set_unlock(lock_set);
606 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
608 lock_set_unlock(lock_set);
717 lock_handoff_accept (lock_set_t lock_set, int lock_id)
723 if (lock_set == LOCK_SET_NULL)
726 if (lock_id < 0 || lock_id >= lock_set->n_ulocks)
730 lock_set_lock(lock_set);
731 if (!lock_set->active) {
732 lock_set_unlock(lock_set);
736 ulock = (ulock_t) &lock_set->ulock_list[lock_id];
738 lock_set_unlock(lock_set);
840 lock_set_reference(lock_set_t lock_set)
842 OSIncrementAtomic(&((lock_set)->ref_count));
852 lock_set_dereference(lock_set_t lock_set)
856 if (1 == OSDecrementAtomic(&((lock_set)->ref_count))) {
857 ipc_port_dealloc_kernel(lock_set->port);
858 size = (int)(sizeof(struct lock_set) +
859 (sizeof(struct ulock) * (lock_set->n_ulocks - 1)));
860 kfree(lock_set, size);