356 * Overview
357 * task_hold_by_id() is used to take a reference on a task by its task id,
358 * supporting the various system call interfaces for obtaining resource data,
359 * delivering signals, and so forth.
360 *
361 * Return values
362 * Returns a pointer to the task_t with taskid_t id. The task is returned
363 * with its hold count incremented by one. Returns NULL if there
364 * is no task with the requested id.
365 *
366 * Caller's context
367 * Caller must not be holding task_hash_lock. No restrictions on context.
368 */
369 task_t *
370 task_hold_by_id_zone(taskid_t id, zoneid_t zoneid)
371 {
372 task_t *tk;
373
374 mutex_enter(&task_hash_lock);
375 if ((tk = task_find(id, zoneid)) != NULL)
376 atomic_add_32(&tk->tk_hold_count, 1);
377 mutex_exit(&task_hash_lock);
378
379 return (tk);
380 }
381
382 task_t *
383 task_hold_by_id(taskid_t id)
384 {
385 zoneid_t zoneid;
386
387 if (INGLOBALZONE(curproc))
388 zoneid = ALL_ZONES;
389 else
390 zoneid = getzoneid();
391 return (task_hold_by_id_zone(id, zoneid));
392 }
393
394 /*
395 * void task_hold(task_t *)
396 *
397 * Overview
398 * task_hold() is used to take an additional reference to the given task.
399 *
400 * Return values
401 * None.
402 *
403 * Caller's context
404 * No restriction on context.
405 */
406 void
407 task_hold(task_t *tk)
408 {
409 atomic_add_32(&tk->tk_hold_count, 1);
410 }
411
412 /*
413 * void task_rele(task_t *)
414 *
415 * Overview
416 * task_rele() relinquishes a reference on the given task, which was acquired
417 * via task_hold() or task_hold_by_id(). If this is the last member or
418 * observer of the task, dispatch it for commitment via the accounting
419 * subsystem.
420 *
421 * Return values
422 * None.
423 *
424 * Caller's context
425 * Caller must not be holding the task_hash_lock.
426 */
427 void
428 task_rele(task_t *tk)
429 {
|
356 * Overview
357 * task_hold_by_id() is used to take a reference on a task by its task id,
358 * supporting the various system call interfaces for obtaining resource data,
359 * delivering signals, and so forth.
360 *
361 * Return values
362 * Returns a pointer to the task_t with taskid_t id. The task is returned
363 * with its hold count incremented by one. Returns NULL if there
364 * is no task with the requested id.
365 *
366 * Caller's context
367 * Caller must not be holding task_hash_lock. No restrictions on context.
368 */
369 task_t *
370 task_hold_by_id_zone(taskid_t id, zoneid_t zoneid)
371 {
372 task_t *tk;
373
374 mutex_enter(&task_hash_lock);
375 if ((tk = task_find(id, zoneid)) != NULL)
376 atomic_inc_32(&tk->tk_hold_count);
377 mutex_exit(&task_hash_lock);
378
379 return (tk);
380 }
381
382 task_t *
383 task_hold_by_id(taskid_t id)
384 {
385 zoneid_t zoneid;
386
387 if (INGLOBALZONE(curproc))
388 zoneid = ALL_ZONES;
389 else
390 zoneid = getzoneid();
391 return (task_hold_by_id_zone(id, zoneid));
392 }
393
394 /*
395 * void task_hold(task_t *)
396 *
397 * Overview
398 * task_hold() is used to take an additional reference to the given task.
399 *
400 * Return values
401 * None.
402 *
403 * Caller's context
404 * No restriction on context.
405 */
406 void
407 task_hold(task_t *tk)
408 {
409 atomic_inc_32(&tk->tk_hold_count);
410 }
411
412 /*
413 * void task_rele(task_t *)
414 *
415 * Overview
416 * task_rele() relinquishes a reference on the given task, which was acquired
417 * via task_hold() or task_hold_by_id(). If this is the last member or
418 * observer of the task, dispatch it for commitment via the accounting
419 * subsystem.
420 *
421 * Return values
422 * None.
423 *
424 * Caller's context
425 * Caller must not be holding the task_hash_lock.
426 */
427 void
428 task_rele(task_t *tk)
429 {
|