• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/xnu-2782.1.97/osfmk/kern/

Lines Matching refs:thread

65  * running a thread that should be SFI-ed are sent an AST.
87 * The wait queue will take the thread's scheduling lock. We may also take
89 * if the thread should block in the wait queue, but the lock will be
348 /* Iterate over processors, call cause_ast_check() on ones running a thread that should be in an off phase */
664 * role of quickly categorizing a thread into its SFI class so that an AST_SFI can be
665 * set. As the thread is unwinding to userspace, sfi_ast() performs full locking
666 * and determines whether the thread should enter an SFI wait state. Because of
668 * thread classification can be inaccurate (but should always be safe). This is
670 * classify the active thread on a remote processor without taking the thread lock.
672 * thread at all, and wait for the thread itself to either hit a quantum expiration
680 sfi_class_id_t sfi_thread_classify(thread_t thread)
682 task_t task = thread->task;
684 sched_mode_t thmode = thread->sched_mode;
687 int thread_bg = proc_get_effective_thread_policy(thread, TASK_POLICY_DARWIN_BG);
689 int thread_qos = proc_get_effective_thread_policy(thread, TASK_POLICY_QOS);
767 * thread must be locked. This is inherently racy, with the intent that
771 ast_t sfi_thread_needs_ast(thread_t thread, sfi_class_id_t *out_class)
775 class_id = sfi_thread_classify(thread);
789 * the currently running thread which is cached on
792 * to evaluate if the current running thread at that
833 * Called at AST context to fully evaluate if the current thread
838 void sfi_ast(thread_t thread)
857 * There is no point putting this thread on a deferred ready
867 thread_lock(thread);
868 thread->sfi_class = class_id = sfi_thread_classify(thread);
869 tid = thread_tid(thread);
872 * Once the sfi_lock is taken and the thread's ->sfi_class field is updated, we
874 * If another thread tries to call sfi_reevaluate() after this point, it will take the
875 * sfi_lock and see the thread in this wait state. If another thread calls
876 * sfi_reevaluate() before this point, it would see a runnable thread and at most
881 /* Optimistically clear workq callback while thread is already locked */
882 if (workq_callback && (thread->sched_call == workq_callback)) {
883 thread_sched_call(thread, NULL);
886 thread_unlock(thread);
890 /* Need to block thread in wait queue */
898 thread->sfi_wait_class = class_id;
902 /* thread may be exiting already, all other errors are unexpected */
915 thread_lock(thread);
916 thread_sched_call(thread, workq_callback);
917 thread_unlock(thread);
924 void sfi_reevaluate(thread_t thread)
935 thread_lock(thread);
936 sfi_ast = sfi_thread_needs_ast(thread, &class_id);
937 thread->sfi_class = class_id;
943 * If we calculate that a thread is in a different ->sfi_wait_class
947 * If the thread is in SFI wait and should not be (or should be waiting
949 * thread may immediately block again in the different SFI wait state.
951 * If the thread is not in an SFI wait state and it should be, we need
952 * to get that thread's attention, possibly by sending an AST to another
956 if ((current_class_id = thread->sfi_wait_class) != SFI_CLASS_UNSPECIFIED) {
958 thread_unlock(thread); /* not needed anymore */
965 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_SFI, SFI_WAIT_CANCELED), thread_tid(thread), current_class_id, class_id, 0, 0);
969 thread,
979 if ((thread->state & (TH_RUN | TH_IDLE)) == TH_RUN) {
981 if (thread == current_thread())
984 processor_t processor = thread->last_processor;
988 processor->active_thread == thread) {
992 * Runnable thread that's not on a CPU currently. When a processor
994 * the thread is in its "off time".
1001 thread_unlock(thread);