class JobDispatcher
Defined at line 75 of file ../../zircon/kernel/object/include/object/job_dispatcher.h
This class implements the Job object kernel interface. Each Job has a parent
Job and zero or more child Jobs and zero or more Child processes. This
creates a DAG (tree) that connects every living task in the system.
This is critically important because of the bottoms up refcount nature of
the system in which the scheduler keeps alive the thread and the thread keeps
alive the process, so without the Job it would not be possible to enumerate
or control the tasks in the system for which there are no outstanding handles.
The second important job of the Job is to apply policies that cannot otherwise
be easily enforced by capabilities, for example kernel object creation.
The third one is to support exception propagation from the leaf tasks to
the root tasks.
Obviously there is a special case for the 'root' Job which its parent is null
and in the current implementation will call platform_halt() when its process
and job count reaches zero. The root job is not exposed to user mode, instead
the single child Job of the root job is given to the userboot process.
Public Methods
zx_obj_type_t get_type ()
Dispatcher implementation.
Defined at line 92 of file ../../zircon/kernel/object/include/object/job_dispatcher.h
fbl::RefPtr<JobDispatcher> parent ()
Defined at line 94 of file ../../zircon/kernel/object/include/object/job_dispatcher.h
uint32_t max_height ()
Defined at line 99 of file ../../zircon/kernel/object/include/object/job_dispatcher.h
fbl::RefPtr<JobDispatcher> CreateRootJob ()
Defined at line 140 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t Create (uint32_t flags, const fbl::RefPtr<JobDispatcher> & parent, KernelHandle<JobDispatcher> * handle, zx_rights_t * rights)
Defined at line 151 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_info_task_runtime_t GetRuntimeStats ()
Defined at line 184 of file ../../zircon/kernel/object/include/object/job_dispatcher.h
void ~JobDispatcher ()
Defined at line 186 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_koid_t get_related_koid ()
Defined at line 194 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t get_name (char (&)[32] out_name)
Job methods.
Defined at line 670 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t set_name (const char * name, size_t len)
Defined at line 677 of file ../../zircon/kernel/object/job_dispatcher.cc
bool AddChildProcess (const fbl::RefPtr<ProcessDispatcher> & process)
Defined at line 196 of file ../../zircon/kernel/object/job_dispatcher.cc
void RemoveChildProcess (ProcessDispatcher * process)
Defined at line 231 of file ../../zircon/kernel/object/job_dispatcher.cc
bool Kill (int64_t return_code)
Terminate the child processes and jobs. Returns |false| if the job is already
in the process of killing, or the children are already terminated. Regardless
of return value, the Job now will not accept new children and eventually
transitions to |DEAD|. |return_code| can be obtained via ZX_INFO_JOB.
Defined at line 395 of file ../../zircon/kernel/object/job_dispatcher.cc
void CriticalProcessKill (fbl::RefPtr<ProcessDispatcher> dead_process)
Called instead of Kill(ZX_TASK_RETCODE_CRITICAL_PROCESS_KILL)
for the case of critical-to-job process death.
Defined at line 458 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t SetBasicPolicy (uint32_t mode, const zx_policy_basic_v1 * in_policy, size_t policy_count)
V1 flavor (on its way out)
Defined at line 488 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t SetBasicPolicy (uint32_t mode, const zx_policy_basic_v2 * in_policy, size_t policy_count)
V2 flavor (on its way in)
Defined at line 505 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t SetTimerSlackPolicy (const zx_policy_timer_slack & policy)
Set timer slack policy.
|policy.min_slack| must be >= 0.
|policy.default_mode| must be one of ZX_TIMER_SLACK_CENTER, ZX_TIMER_SLACK_EARLY,
ZX_TIMER_SLACK_LATE.
It is an error to set policy on a non-empty job, i.e. a job with one or more sub-jobs or
processes.
Defined at line 515 of file ../../zircon/kernel/object/job_dispatcher.cc
JobPolicy GetPolicy ()
Defined at line 336 of file ../../zircon/kernel/object/job_dispatcher.cc
bool KillJobWithKillOnOOM ()
Kills its lowest child job that has get_kill_on_oom() set.
Returns false if no alive child job had get_kill_on_oom() set.
Defined at line 341 of file ../../zircon/kernel/object/job_dispatcher.cc
bool EnumerateChildren (JobEnumerator * je)
Enumerates the direct (non recursive) children and invokes |je| methods on
each node. The |je| methods are invoked without the lock of this
JobDispatcher held, however a consistent atomic snapshot of children will
be given. Returns false if any methods of |je| return false; returns true
otherwise.
Defined at line 550 of file ../../zircon/kernel/object/job_dispatcher.cc
bool EnumerateChildrenRecursive (JobEnumerator * je)
Recursively walks the job/process tree and invokes |je| methods on each
node. The |je| methods are invoked with all parent |JobDispatcher| object
locks held. Returns false if any methods of |je| return false; returns true
otherwise.
Defined at line 593 of file ../../zircon/kernel/object/job_dispatcher.cc
fbl::RefPtr<ProcessDispatcher> LookupProcessById (zx_koid_t koid)
Defined at line 626 of file ../../zircon/kernel/object/job_dispatcher.cc
fbl::RefPtr<JobDispatcher> LookupJobById (zx_koid_t koid)
Defined at line 648 of file ../../zircon/kernel/object/job_dispatcher.cc
Exceptionate * exceptionate ()
It's safe to return a raw pointer because the exceptionate is only used by the threads under
the current job.
Defined at line 683 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t ForEachDebugExceptionate (fit::inline_function<void (Exceptionate *)> func)
Enumerate over a snapshot of debug exceptionates. |func| will be called without the lock held.
Defined at line 688 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_status_t CreateDebugExceptionate (KernelHandle<ChannelDispatcher> channel_handle, zx_rights_t thread_rights, zx_rights_t process_rights)
Create a new debug exceptionate. Possible errors are ZX_ERR_NO_MEMORY and ZX_ERR_ALREADY_BOUND.
Instead of return an exceptionate, this function calls SetChannel directly because it needs to
be protected by our lock.
Defined at line 722 of file ../../zircon/kernel/object/job_dispatcher.cc
void set_kill_on_oom (bool kill)
Defined at line 754 of file ../../zircon/kernel/object/job_dispatcher.cc
bool get_kill_on_oom ()
Defined at line 759 of file ../../zircon/kernel/object/job_dispatcher.cc
zx_info_job_t GetInfo ()
Defined at line 764 of file ../../zircon/kernel/object/job_dispatcher.cc
TaskRuntimeStats GetTaskRuntimeStats ()
Aggregate the runtime for all processes that were previously running or are currently running
as children of this job.
This includes runtime for threads that previously ran under those processes, but it does not
include runtime for child jobs.
Defined at line 776 of file ../../zircon/kernel/object/job_dispatcher.cc
uint32_t LockOrder ()
To come up with an order on our recursive locks we take advantage of the fact that our
max_height reduces from parent to child. As we acquire locks from parent->child we can build an
increasing counter by inverting the max_height. We add 1 to the counter just so the order value
of 0 is reserved for the default order when the lock is acquired without an order being
specified.
Defined at line 52 of file ../../zircon/kernel/object/job_dispatcher.cc