Skip to main content

ThreadOwnership

Enum ThreadOwnership 

Source
pub enum ThreadOwnership {
    Tool,
    Host,
}
Expand description

Who owns a guest thread: the single axis that governs both how the thread executes and who owns its thread-synchronization primitives (futex, CLONE_CHILD_CLEARTID).

These two concerns must never disagree. If a thread executes under the Tool (registered in the Tool’s scheduler) while its futex is serviced by the host — or vice versa — a pthread_join deadlocks: the joiner’s FUTEX_WAIT waits in one domain while the exiting thread’s CLEARTID wake fires in the other, so the wake never reaches the waiter. Collapsing both concerns onto this single enum makes that split-brain state unrepresentable: a thread is either wholly Tool-owned or wholly Host-owned, never half of each.

A backend that runs child threads (e.g. the KVM backend, where each guest thread runs on its own vCPU) selects the ownership for a tool’s threads from Tool::thread_ownership and uses the same value to decide (a) whether to drive the thread through the Tool loop and (b) whether its futex routes to the Tool. Backends that do not run child threads (e.g. ptrace, which already routes every subscribed futex to the Tool) may ignore this value.

Variants§

§

Tool

The Tool owns the thread: it is driven through the Tool loop (so the Tool observes every one of its syscalls and schedules it) and its futex / CLEARTID synchronization is serviced by the Tool. This is the safe, “follow children” default — it matches the golden ptrace backend, where the Tool (Detcore) owns every futex and no thread synchronization touches the host. Determinism can only be guaranteed for Tool-owned threads.

§

Host

The host owns the thread: it runs uninstrumented on the backend’s direct execution personality and its futex / CLEARTID synchronization uses real host futex words.

This is the unmonitored_ opt-out. It is internally consistent (host execution + host futex, so it does not by itself deadlock a join), but it is a determinism/coverage hazard, not a correctness shortcut:

  • The Tool never sees the thread’s syscalls, so it cannot sanitize, record, or schedule them — determinism is not guaranteed for it or for anything ordered against it.
  • Mixing Host-owned threads into a tool that expects to schedule the whole thread group (e.g. Detcore) breaks that tool’s model.

It is deliberately not named unsafe_: it cannot cause undefined behavior, only nondeterminism and missed instrumentation.

Implementations§

Source§

impl ThreadOwnership

Source

pub fn executes_on_tool(self) -> bool

Whether a thread with this ownership executes under the Tool loop (as opposed to the backend’s direct host execution personality).

Source

pub fn executes_on_host(self) -> bool

Whether a thread with this ownership executes on the backend’s direct host execution personality (as opposed to the Tool loop). The exact inverse of Self::executes_on_tool.

Source

pub fn futex_is_host_owned(self) -> bool

Whether the thread’s futex / CLEARTID synchronization is serviced by the host rather than the Tool. This is the exact inverse of Self::executes_on_tool; the two are derived from the same value so execution and synchronization ownership can never disagree.

Trait Implementations§

Source§

impl Clone for ThreadOwnership

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ThreadOwnership

Source§

impl Debug for ThreadOwnership

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ThreadOwnership

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ThreadOwnership

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ThreadOwnership

Source§

impl PartialEq for ThreadOwnership

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ThreadOwnership

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ThreadOwnership

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.