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
impl ThreadOwnership
Sourcepub fn executes_on_tool(self) -> bool
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).
Sourcepub fn executes_on_host(self) -> bool
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.
Sourcepub fn futex_is_host_owned(self) -> bool
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
impl Clone for ThreadOwnership
impl Copy for ThreadOwnership
Source§impl Debug for ThreadOwnership
impl Debug for ThreadOwnership
Source§impl Default for ThreadOwnership
impl Default for ThreadOwnership
Source§impl<'de> Deserialize<'de> for ThreadOwnership
impl<'de> Deserialize<'de> for ThreadOwnership
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ThreadOwnership
Source§impl PartialEq for ThreadOwnership
impl PartialEq for ThreadOwnership
Source§impl Serialize for ThreadOwnership
impl Serialize for ThreadOwnership
impl StructuralPartialEq for ThreadOwnership
Auto Trait Implementations§
impl Freeze for ThreadOwnership
impl RefUnwindSafe for ThreadOwnership
impl Send for ThreadOwnership
impl Sync for ThreadOwnership
impl Unpin for ThreadOwnership
impl UnsafeUnpin for ThreadOwnership
impl UnwindSafe for ThreadOwnership
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.