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

Lines Matching defs:thread

59  *	File:	kern/thread.c
93 #include <machine/thread.h>
111 #include <kern/thread.h>
142 static struct thread thread_template, init_thread;
146 thread_t thread);
156 * Fill in a template thread for fast initialization.
247 sizeof(struct thread),
248 THREAD_MAX * sizeof(struct thread),
249 THREAD_CHUNK * sizeof(struct thread),
256 * per-thread structures necessary.
274 thread_t thread = current_thread();
279 thread_mtx_lock(thread);
281 ulock_release_all(thread);
283 ipc_thread_disable(thread);
285 thread_mtx_unlock(thread);
288 thread_lock(thread);
294 if (thread->sched_mode & TH_MODE_ISDEPRESSED) {
295 thread->sched_mode &= ~TH_MODE_ISDEPRESSED;
297 if (timer_call_cancel(&thread->depress_timer))
298 thread->depress_timer_active--;
301 while (thread->depress_timer_active > 0) {
302 thread_unlock(thread);
308 thread_lock(thread);
311 thread_unlock(thread);
314 thread_policy_reset(thread);
317 * If we are the last thread to terminate and the task is
320 task = thread->task;
321 uthread_cleanup(task, thread->uthread, task->bsd_info);
330 uthread_cred_free(thread->uthread);
333 thread_lock(thread);
339 if (thread->wait_timer_is_set) {
340 thread->wait_timer_is_set = FALSE;
342 if (timer_call_cancel(&thread->wait_timer))
343 thread->wait_timer_active--;
346 while (thread->wait_timer_active > 0) {
347 thread_unlock(thread);
353 thread_lock(thread);
359 if (thread->reserved_stack != 0) {
360 if (thread->reserved_stack != thread->kernel_stack)
361 stack_free_stack(thread->reserved_stack);
362 thread->reserved_stack = 0;
366 * Mark thread as terminating, and block.
368 thread->state |= TH_TERMINATE;
369 thread_mark_wait_locked(thread, THREAD_UNINT);
370 assert(thread->promotions == 0);
371 thread_unlock(thread);
380 thread_t thread)
384 if (thread == THREAD_NULL)
387 if (thread_deallocate_internal(thread) > 0)
390 ipc_thread_terminate(thread);
392 task = thread->task;
396 void *ut = thread->uthread;
398 thread->uthread = NULL;
405 if (thread->kernel_stack != 0)
406 stack_free(thread);
408 machine_thread_destroy(thread);
410 zfree(thread_zone, thread);
421 thread_t thread;
427 while ((thread = (thread_t)dequeue_head(&thread_terminate_queue)) != THREAD_NULL) {
431 task = thread->task;
434 task->total_user_time += timer_grab(&thread->user_timer);
435 task->total_system_time += timer_grab(&thread->system_timer);
437 task->c_switch += thread->c_switch;
438 task->p_switch += thread->p_switch;
439 task->ps_switch += thread->ps_switch;
441 queue_remove(&task->threads, thread, thread_t, task_threads);
446 queue_remove(&threads, thread, thread_t, threads);
450 thread_deallocate(thread);
467 * Enqueue a terminating thread for final disposition.
473 thread_t thread)
476 enqueue_tail(&thread_terminate_queue, (queue_entry_t)thread);
491 thread_t thread;
495 while ((thread = (thread_t)dequeue_head(&thread_stack_queue)) != THREAD_NULL) {
498 stack_alloc(thread);
501 thread_lock(thread);
502 thread_setrun(thread, SCHED_PREEMPT | SCHED_TAILQ);
503 thread_unlock(thread);
519 * Enqueue a thread for stack allocation.
525 thread_t thread)
528 enqueue_tail(&thread_stack_queue, (queue_entry_t)thread);
538 thread_t thread;
543 result = kernel_thread_start_priority((thread_continue_t)thread_terminate_daemon, NULL, MINPRI_KERNEL, &thread);
547 thread_deallocate(thread);
552 result = kernel_thread_start_priority((thread_continue_t)thread_stack_daemon, NULL, BASEPRI_PREEMPT, &thread);
556 thread_deallocate(thread);
560 * Create a new thread.
561 * Doesn't start the thread running.
574 * Allocate a thread and initialize static fields
656 /* Chain the thread onto the task's list */
669 /* Set the thread's scheduling parameters */
715 thread_t thread;
720 result = thread_create_internal(task, -1, (thread_continue_t)thread_bootstrap_return, &thread);
724 thread->user_stop_count = 1;
725 thread_hold(thread);
727 thread_hold(thread);
732 *new_thread = thread;
746 thread_t thread;
751 result = thread_create_internal(task, -1, (thread_continue_t)thread_bootstrap_return, &thread);
756 thread, flavor, new_state, new_state_count);
761 thread_terminate(thread);
762 thread_deallocate(thread);
766 thread_mtx_lock(thread);
767 thread_start_internal(thread);
768 thread_mtx_unlock(thread);
773 *new_thread = thread;
781 * Create a thread in the kernel task
792 thread_t thread;
795 result = thread_create_internal(task, priority, continuation, &thread);
802 stack_alloc(thread);
803 assert(thread->kernel_stack != 0);
807 thread->reserved_stack = thread->kernel_stack;
809 thread->parameter = parameter;
812 kprintf("kernel_thread_create: thread = %p continuation = %p\n", thread, continuation);
813 *new_thread = thread;
826 thread_t thread;
828 result = kernel_thread_create(continuation, parameter, priority, &thread);
832 thread_mtx_lock(thread);
833 thread_start_internal(thread);
834 thread_mtx_unlock(thread);
836 *new_thread = thread;
856 thread_t thread;
861 result = kernel_thread_start_priority((thread_continue_t)start, NULL, -1, &thread);
865 thread_deallocate(thread);
867 return (thread);
872 register thread_t thread,
880 if (thread == THREAD_NULL)
892 thread_lock(thread);
896 thread_read_times(thread, &basic_info->user_time,
902 if (thread->sched_stamp != sched_tick)
903 update_priority(thread);
912 basic_info->cpu_usage = ((uint64_t)thread->cpu_usage
919 basic_info->policy = ((thread->sched_mode & TH_MODE_TIMESHARE)?
923 if (thread->bound_processor != PROCESSOR_NULL && thread->bound_processor->idle_thread == thread)
926 if (!thread->kernel_stack)
930 if (thread->state & TH_TERMINATE)
933 if (thread->state & TH_RUN)
936 if (thread->state & TH_UNINT)
939 if (thread->state & TH_SUSP)
942 if (thread->state & TH_WAIT)
948 basic_info->suspend_count = thread->user_stop_count;
950 thread_unlock(thread);
967 thread_lock(thread);
969 if (!(thread->sched_mode & TH_MODE_TIMESHARE)) {
970 thread_unlock(thread);
976 ts_info->depressed = (thread->sched_mode & TH_MODE_ISDEPRESSED) != 0;
979 ts_info->depress_priority = thread->priority;
982 ts_info->base_priority = thread->priority;
986 ts_info->cur_priority = thread->sched_pri;
987 ts_info->max_priority = thread->max_priority;
989 thread_unlock(thread);
1013 thread_lock(thread);
1015 if (thread->sched_mode & TH_MODE_TIMESHARE) {
1016 thread_unlock(thread);
1022 rr_info->depressed = (thread->sched_mode & TH_MODE_ISDEPRESSED) != 0;
1025 rr_info->depress_priority = thread->priority;
1028 rr_info->base_priority = thread->priority;
1032 rr_info->max_priority = thread->max_priority;
1035 thread_unlock(thread);
1048 thread_t thread,
1052 absolutetime_to_microtime(timer_grab(&thread->user_timer),
1056 absolutetime_to_microtime(timer_grab(&thread->system_timer),
1063 __unused thread_t thread,
1077 thread_t thread)
1079 return (thread_assign(thread, &pset0));
1085 * Return current assignment for this thread.
1089 thread_t thread,
1092 if (thread == NULL)
1103 * Specify that the target thread must always be able
1109 thread_t thread,
1113 if (host_priv == NULL || thread != current_thread())
1119 *prev_state = (thread->options & TH_OPT_VMPRIV) != 0;
1122 if (!(thread->options & TH_OPT_VMPRIV))
1124 thread->options |= TH_OPT_VMPRIV;
1127 if (thread->options & TH_OPT_VMPRIV)
1129 thread->options &= ~TH_OPT_VMPRIV;
1144 thread_t thread,
1147 return (thread_wire_internal(host_priv, thread, wired, NULL));
1270 __unused thread_t thread)
1277 thread_t thread,
1280 thread->sched_call = (call != NULL)? call: sched_call_null;
1285 thread_t thread,
1288 thread_mtx_lock(thread);
1289 thread->static_param = state;
1290 thread_mtx_unlock(thread);
1299 void thread_reference(thread_t thread);
1302 thread_t thread)
1304 if (thread != THREAD_NULL)
1305 thread_reference_internal(thread);
1318 uint32_t dtrace_get_thread_predcache(thread_t thread)
1320 if (thread != THREAD_NULL)
1321 return thread->t_dtrace_predcache;
1326 int64_t dtrace_get_thread_vtime(thread_t thread)
1328 if (thread != THREAD_NULL)
1329 return thread->t_dtrace_vtime;
1334 int64_t dtrace_get_thread_tracing(thread_t thread)
1336 if (thread != THREAD_NULL)
1337 return thread->t_dtrace_tracing;
1342 boolean_t dtrace_get_thread_reentering(thread_t thread)
1344 if (thread != THREAD_NULL)
1345 return (thread->options & TH_OPT_DTRACE) ? TRUE : FALSE;
1350 vm_offset_t dtrace_get_kernel_stack(thread_t thread)
1352 if (thread != THREAD_NULL)
1353 return thread->kernel_stack;
1358 int64_t dtrace_calc_thread_recent_vtime(thread_t thread)
1361 if (thread != THREAD_NULL) {
1362 return timer_grab(&(thread->system_timer)) + timer_grab(&(thread->user_timer));
1366 if (thread != THREAD_NULL) {
1373 return timer_grab(&(thread->system_timer)) + timer_grab(&(thread->user_timer)) +
1380 void dtrace_set_thread_predcache(thread_t thread, uint32_t predcache)
1382 if (thread != THREAD_NULL)
1383 thread->t_dtrace_predcache = predcache;
1386 void dtrace_set_thread_vtime(thread_t thread, int64_t vtime)
1388 if (thread != THREAD_NULL)
1389 thread->t_dtrace_vtime = vtime;
1392 void dtrace_set_thread_tracing(thread_t thread, int64_t accum)
1394 if (thread != THREAD_NULL)
1395 thread->t_dtrace_tracing = accum;
1398 void dtrace_set_thread_reentering(thread_t thread, boolean_t vbool)
1400 if (thread != THREAD_NULL) {
1402 thread->options |= TH_OPT_DTRACE;
1404 thread->options &= (~TH_OPT_DTRACE);
1408 vm_offset_t dtrace_set_thread_recover(thread_t thread, vm_offset_t recover)
1412 if (thread != THREAD_NULL) {
1413 prev = thread->recover;
1414 thread->recover = recover;