class ThreadDispatcher

Defined at line 38 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

Public Methods

zx_status_t Create (fbl::RefPtr<ProcessDispatcher> process, uint32_t flags, ktl::string_view name, KernelHandle<ThreadDispatcher> * out_handle, zx_rights_t * out_rights)

static

Defined at line 43 of file ../../zircon/kernel/object/thread_dispatcher.cc

ThreadDispatcher * GetCurrent ()

Defined at line 74 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

void ExitCurrent ()

Terminates the current thread. Does not return.

Defined at line 77 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

void KillCurrent ()

Marks the current thread for termination. The thread will actually termiante when

the kernel stack unwinds.

Defined at line 80 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

zx_obj_type_t get_type ()

Dispatcher implementation.

Defined at line 83 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

void ~ThreadDispatcher ()

Defined at line 83 of file ../../zircon/kernel/object/thread_dispatcher.cc

void set_is_initial_thread (bool is_initial_thread)

Sets whether or not this is the initial thread in its process.

Should only be called by ProcessDispatcher upon adding the initialized thread.

Defined at line 88 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

zx_status_t Initialize ()

Performs initialization on a newly constructed ThreadDispatcher

If this fails, then the object is invalid and should be deleted

Defined at line 108 of file ../../zircon/kernel/object/thread_dispatcher.cc

ProcessDispatcher * process ()

accessors

Defined at line 116 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

zx_status_t Start (const EntryState & entry, bool ensure_initial_thread)

Start this thread running inside the parent process with the provided entry state, only

valid to be called on a thread in the INITIALIZED state that has not yet been started. If

`ensure_initial_thread` is true, the thread will only start if it is the first thread in the

process.

Defined at line 154 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t MakeRunnable (const EntryState & entry, bool suspended)

Transitions a thread from the INITIALIZED state to either the RUNNING or SUSPENDED state.

Is the caller's responsibility to ensure this thread is registered with the parent process,

as such this is only expected to be called from the ProcessDispatcher.

Defined at line 164 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t set_name (const char * name, size_t len)

Defined at line 127 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_info_task_runtime_t GetRuntimeStats ()

Defined at line 175 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

ChannelDispatcher::MessageWaiter * GetMessageWaiter ()

For ChannelDispatcher use.

Defined at line 188 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

void Kill ()

Defined at line 208 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t Suspend ()

Suspends the thread.

Returns ZX_OK on success, or ZX_ERR_BAD_STATE iff the thread is dying or dead.

Defined at line 235 of file ../../zircon/kernel/object/thread_dispatcher.cc

void Resume ()

Defined at line 273 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t get_name (char (&)[32] out_name)

Defined at line 140 of file ../../zircon/kernel/object/thread_dispatcher.cc

CoreThreadObservation ObserveCoreThread ()

Defined at line 282 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

zx_koid_t get_related_koid ()

Defined at line 903 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t RestrictedKick ()

Issues a restricted kick on the thread which will kick the thread out of restricted

mode to normal mode if it's currently in restricted mode or remember the kick state for

the next attempt to enter restricted state.

Returns ZX_OK on success or ZX_ERR_BAD_STATE iff the thread is dying or dead.

Defined at line 303 of file ../../zircon/kernel/object/thread_dispatcher.cc

bool IsDyingOrDead ()

Returns true if the thread is dying or dead. Threads never return to a previous state

from dying/dead so once this is true it will never flip back to false.

Defined at line 328 of file ../../zircon/kernel/object/thread_dispatcher.cc

bool HasStarted ()

Returns true if the thread was ever started (even if it is dead now).

Threads never return to an INITIAL state after starting, so once this is

true it will never flip back to false.

Defined at line 338 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t GetExceptionReport (zx_exception_report_t * report)

Assuming the thread is stopped waiting for an exception response,

fill in |*report| with the exception report.

Returns ZX_ERR_BAD_STATE if not in an exception.

Defined at line 638 of file ../../zircon/kernel/object/thread_dispatcher.cc

Exceptionate * exceptionate ()

Defined at line 656 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t HandleException (Exceptionate * exceptionate, fbl::RefPtr<ExceptionDispatcher> exception, bool * sent)

Sends an exception over the exception channel and blocks for a response.

|sent| will indicate whether the exception was successfully sent over

the given |exceptionate| channel. This can be used in the ZX_ERR_NEXT

case to determine whether the exception channel didn't exist or it did

exist but the receiver opted not to handle the exception.

Returns:

ZX_OK if the exception was processed and the thread should resume.

ZX_ERR_NEXT if there is no channel or the receiver opted to skip.

ZX_ERR_NO_MEMORY on allocation failure.

ZX_ERR_INTERNAL_INTR_KILLED if the thread was killed before

receiving a response.

Defined at line 661 of file ../../zircon/kernel/object/thread_dispatcher.cc

bool HandleSingleShotException (Exceptionate * exceptionate, zx_excp_type_t exception_type, const arch_exception_context_t & context)

Similar to HandleException(), but for single-shot exceptions which are

sent to at most one handler, e.g. ZX_EXCP_THREAD_STARTING.

The main difference is that this takes |exception_type| and |context|

rather than a full exception object, and internally sets up the required

state and creates the exception object.

Returns true if the exception was sent.

Defined at line 718 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_info_thread_t GetInfoForUserspace ()

Fetch the state of the thread for userspace tools.

Defined at line 573 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t GetStatsForUserspace (zx_info_thread_stats_t * info)

Fetch per thread stats for userspace.

Defined at line 599 of file ../../zircon/kernel/object/thread_dispatcher.cc

TaskRuntimeStats GetCompensatedTaskRuntimeStats ()

Fetch a consistent snapshot of the runtime stats, compensated for unaccumulated runtime in the

ready or running state.

Defined at line 617 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t ReadState (zx_thread_state_topic_t state_kind, user_out_ptr<void> buffer, size_t buffer_size)

For debugger usage.

Defined at line 783 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t WriteState (zx_thread_state_topic_t state_kind, user_in_ptr<const void> buffer, size_t buffer_size)

Defined at line 834 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t SetBaseProfile (const SchedulerState::BaseProfile & profile)

Profile support

Defined at line 860 of file ../../zircon/kernel/object/thread_dispatcher.cc

zx_status_t SetSoftAffinity (cpu_mask_t mask)

Defined at line 873 of file ../../zircon/kernel/object/thread_dispatcher.cc

void ExitingCurrent ()

This is called from Thread as it is exiting, just before it stops for good.

It is an error to call this on anything other than the current thread.

Defined at line 349 of file ../../zircon/kernel/object/thread_dispatcher.cc

void Suspending ()

callback from kernel when thread is suspending

Defined at line 408 of file ../../zircon/kernel/object/thread_dispatcher.cc

void Resuming ()

callback from kernel when thread is resuming

Defined at line 425 of file ../../zircon/kernel/object/thread_dispatcher.cc

void UpdateRuntimeStats (thread_state new_state)

Update the runtime stats for this thread/process. This is called by

Scheduler to update the runtime stats of the thread as it changes thread

state.

Must be called with interrupts disabled.

Defined at line 622 of file ../../zircon/kernel/object/thread_dispatcher.cc

void AddPageFaultTicks (zx_duration_mono_ticks_t ticks)

Update time spent handling page faults. This is called by the VM during page fault handling.

Defined at line 628 of file ../../zircon/kernel/object/thread_dispatcher.cc

void AddLockContentionTicks (zx_duration_mono_ticks_t ticks)

Update time spent contended on locks. This is called by lock implementations.

Defined at line 633 of file ../../zircon/kernel/object/thread_dispatcher.cc

Enumerations

enum Blocked
Name Value
NONE 0
EXCEPTION 1
SLEEPING 2
FUTEX 3
PORT 4
CHANNEL 5
WAIT_ONE 6
WAIT_MANY 7
INTERRUPT 8
PAGER 9

When in a blocking syscall, or blocked in an exception, the blocking reason.

There is one of these for each syscall marked "blocking".

See //zircon/vdso.

Defined at line 44 of file ../../zircon/kernel/object/include/object/thread_dispatcher.h

Records

Friends

class OwnedWaitQueue
class FutexContext