-/*
- * task_collect_scan:
- *
- * Attempt to free resources owned by tasks.
- */
-
-void
-task_collect_scan(void)
-{
- register task_t task, prev_task;
- processor_set_t pset = &default_pset;
-
- pset_lock(pset);
- pset->ref_count++;
- task = (task_t) queue_first(&pset->tasks);
- while (!queue_end(&pset->tasks, (queue_entry_t) task)) {
- task_lock(task);
- if (task->ref_count > 0) {
-
- task_reference_locked(task);
- task_unlock(task);
-
-#if MACH_HOST
- /*
- * While we still have the pset locked, freeze the task in
- * this pset. That way, when we get back from collecting
- * it, we can dereference the pset_tasks chain for the task
- * and be assured that we are still in this chain.
- */
- task_freeze(task);
-#endif
-
- pset_unlock(pset);
-
- pmap_collect(task->map->pmap);
-
- pset_lock(pset);
- prev_task = task;
- task = (task_t) queue_next(&task->pset_tasks);
-
-#if MACH_HOST
- task_unfreeze(prev_task);
-#endif
-
- task_deallocate(prev_task);
- } else {
- task_unlock(task);
- task = (task_t) queue_next(&task->pset_tasks);
- }
- }
-
- pset_unlock(pset);
-
- pset_deallocate(pset);
-}
-
-/* Also disabled in vm/vm_pageout.c */
-boolean_t task_collect_allowed = FALSE;
-unsigned task_collect_last_tick = 0;
-unsigned task_collect_max_rate = 0; /* in ticks */
-
-/*
- * consider_task_collect:
- *
- * Called by the pageout daemon when the system needs more free pages.
- */
-
-void
-consider_task_collect(void)
-{
- /*
- * By default, don't attempt task collection more frequently
- * than once per second.
- */
-
- if (task_collect_max_rate == 0)
- task_collect_max_rate = (1 << SCHED_TICK_SHIFT) + 1;
-
- if (task_collect_allowed &&
- (sched_tick > (task_collect_last_tick + task_collect_max_rate))) {
- task_collect_last_tick = sched_tick;
- task_collect_scan();
- }
-}
-