pub struct ThreadState<T> {Show 25 fields
pub dettid: DetTid,
pub detpid: Option<DetTid>,
pub physical_tid: Option<i32>,
pub mm_id: MmId,
pub pedigree: Pedigree,
pub stats: ThreadStats,
pub preemption_points: Option<ThreadHistoryIterator>,
pub interrupt_at: BTreeSet<u64>,
pub clone_flags: Option<CloneFlags>,
pub pending_vfork: Option<PendingVfork>,
pub file_metadata: Arc<Mutex<FileMetadata>>,
pub prng: Pcg64Mcg,
pub chaos_prng: Pcg64Mcg,
pub thread_logical_time: DetTime,
pub committed_clock_value: u64,
pub record_or_replay: T,
pub end_of_timeslice: Option<LogicalTime>,
pub replay_rcb_end: Option<u64>,
pub chaos_epoch: u64,
pub chaos_slowdown_factor: RcbTimeMultiplier,
pub chaos_slowdown_active: bool,
pub pending_chaos_epochs: Vec<ChaosEpochTransition>,
pub max_timeslice_end: Option<LogicalTime>,
pub last_rcb_timer: Option<u64>,
pub last_rcb_timer_is_max: bool,
/* private fields */
}Expand description
The Detcore per-thread state.
Fields§
§dettid: DetTidThe deterministic thread ID of the this thread.
detpid: Option<DetTid>The deterministic process ID of the this thread.
physical_tid: Option<i32>Host thread ID supplied by a backend whose scheduler identity is
virtual. None keeps the existing direct-ID behavior for other
backends.
mm_id: MmIdLinux memory address space shared by tasks created with CLONE_VM.
pedigree: PedigreeThis threads path within the thread/process ancestry tree. (The terminology comes from Cilk.)
stats: ThreadStatsCounting various events.
preemption_points: Option<ThreadHistoryIterator>In chaos mode with –replay-preemptions-from, we hold a list of our future preemption points.
interrupt_at: BTreeSet<u64>User defined interruption points
clone_flags: Option<CloneFlags>clone flags when SYS_clone is called.
This is just a place to stash the value temporarily, where it can be read out by
the child thread upon init_thread_state. After that point, it is consumed by
the child and becomes None again.
Stated differently, this is just for message-passing communication.
pending_vfork: Option<PendingVfork>Registration metadata for a child whose parent cannot resume until the
backend finishes the child. The child consumes this in
handle_thread_start; the parent clears its copy when injection returns.
file_metadata: Arc<Mutex<FileMetadata>>Shared file metadata among all threads in the same process.
Initialized for new threads (shared or fresh), and then overwritten again on execve.
prng: Pcg64Mcgpseudo random number state
chaos_prng: Pcg64McgRNG to drive chaos scheduling decisions, separate from other (guest) RNG.
thread_logical_time: DetTimelogical time, measuring progress of this thread and only this thread.
committed_clock_value: u64the last RCB clock value committed to thread_logical_time
record_or_replay: TThread state associated with record/replay.
end_of_timeslice: Option<LogicalTime>How much longer does this thread get to run before it must check-in with the scheduler? Note that this notion of time slice can extend across a region of time that includes syscalls (and thus handlers).
If set to None, the thread can run indefinitely without preemption.
This is in units of virtual Nanoseconds. And it is an exact time in the future, not a relative duration.
replay_rcb_end: Option<u64>Exact per-thread PMU RCB target for the active preemption-replay slice.
None selects the legacy logical-time deadline path.
chaos_epoch: u64Deterministic chaos epoch this thread was in at its last next_timeslice.
Used only to detect epoch transitions for CHAOSEPOCH logging; the epoch
itself is recomputed each slice from thread_logical_time. Sentinel
u64::MAX guarantees the first slice always logs its initial epoch.
chaos_slowdown_factor: RcbTimeMultiplierExact multiplier currently used to convert this thread’s RCBs to virtual time.
chaos_slowdown_active: boolTrue when live chaos configuration or a replay artifact supplies the factor.
pending_chaos_epochs: Vec<ChaosEpochTransition>Transitions waiting to be committed into the preemption artifact.
max_timeslice_end: Option<LogicalTime>Absolute deadline enforced by the PMU-backed --max-timeslice timer. This is separate from
end_of_timeslice so syscall-heavy workloads can use a shorter, cheap target deadline.
last_rcb_timer: Option<u64>Track what our last timer was set for, just to double check that RCB timers are behaving as expected and see if we went over. (For exmaple, this behaves badly if threads are not pinned and our we migrate between cores.)
last_rcb_timer_is_max: boolWhether last_rcb_timer represents the maximum deadline rather than a manual interrupt.
Implementations§
Source§impl<T> ThreadState<T>
impl<T> ThreadState<T>
Sourcepub fn reseed_child_rngs(&mut self, parent: &Self, entropy: u128)
pub fn reseed_child_rngs(&mut self, parent: &Self, entropy: u128)
Replaces the host-TID-derived child streams with a backend-provided, deterministic identity before the thread enters its start hook.
Sourcepub fn new(pid: DetPid, cfg: &Config, record_or_replay: T) -> Self
pub fn new(pid: DetPid, cfg: &Config, record_or_replay: T) -> Self
Create a fresh new thread state from nothing. In practice this is only used for the thread state of the root thread of the container.
Sourcepub fn apply_initial_random_state(
&mut self,
bytes: &[u8],
config: &Config,
image: InitialImage,
) -> Result<(), Errno>
pub fn apply_initial_random_state( &mut self, bytes: &[u8], config: &Config, image: InitialImage, ) -> Result<(), Errno>
Apply a required, authenticated initial-image random handoff to the normal root. Errors are tool initialization failures, never guest errno.
Sourcepub fn mk_request(&self, rid: ResourceID, perm: Permission) -> Resources
pub fn mk_request(&self, rid: ResourceID, perm: Permission) -> Resources
Build a singleton resource request from the current thread.
Sourcepub fn chaos_prng_next_u64(&mut self, msg: &str) -> u64
pub fn chaos_prng_next_u64(&mut self, msg: &str) -> u64
Generate the next random number using the thread-local chaos_seed.
Sourcepub fn add_fd(
&self,
fd: RawFd,
flags: OFlag,
ty: FdType,
stat: Option<DetStat>,
) -> Result<(), Errno>
pub fn add_fd( &self, fd: RawFd, flags: OFlag, ty: FdType, stat: Option<DetStat>, ) -> Result<(), Errno>
Add a new fd, with optional stat data, have side effects on other threads.
If stat data is not available, then perform an extra stat ourselves to populate it.
§Arguments
-
fd- file descriptor to add -
flags- flags when creatingfd -
ty- fd type (regular file, socket, pipe, etc..) -
stat- stat returned from fstat
Sourcepub fn set_open_file_creator(&mut self, creator: DetTid)
pub fn set_open_file_creator(&mut self, creator: DetTid)
Overrides the task identity embedded in subsequently allocated open-file descriptions.
Sourcepub fn with_detfd<F, U>(&self, fd: RawFd, f: F) -> Result<U, Errno>where
F: FnMut(&mut DetFd) -> U,
pub fn with_detfd<F, U>(&self, fd: RawFd, f: F) -> Result<U, Errno>where
F: FnMut(&mut DetFd) -> U,
Get a mutable reference of DetFd from a raw file descriptor, and
run mutable function f on it (&mut DetFd).
Sourcepub fn has_unsafe_vfork_flock_state(&self) -> bool
pub fn has_unsafe_vfork_flock_state(&self) -> bool
Whether any open file description is held or not proven unlocked.
Sourcepub fn forget_flock_modes(&self)
pub fn forget_flock_modes(&self)
A new process can change every inherited open file description through a separately hosted tool state, so neither side may keep treating its cached flock mode as authoritative after fork.
Sourcepub fn remove_fd(&self, fd: RawFd) -> Option<OpenFileId>
pub fn remove_fd(&self, fd: RawFd) -> Option<OpenFileId>
remove a rawfd
Sourcepub fn dup_fd(
&mut self,
oldfd: RawFd,
newfd: RawFd,
flags: OFlag,
) -> Result<Option<OpenFileId>, Errno>
pub fn dup_fd( &mut self, oldfd: RawFd, newfd: RawFd, flags: OFlag, ) -> Result<Option<OpenFileId>, Errno>
dup raw fds.
Sourcepub fn thread_prng(&mut self) -> &mut Pcg64Mcg
pub fn thread_prng(&mut self) -> &mut Pcg64Mcg
get thread prng, note this rng is deterministic and should not be used for crypto.
Sourcepub fn next_timeslice(&mut self, cfg: &Config) -> Option<Priority>
pub fn next_timeslice(&mut self, cfg: &Config) -> Option<Priority>
Choose the logical target and PMU maximum deadlines for the next timeslice.
Effects:
- Sets
end_of_timeslicefor the new timeslice. - Sets
max_timeslice_endwhen PMU-backed preemption is enabled. - Resets the statistics for the timeslice.
Returns: an optional new priority.
Sourcepub fn reset_timeslice_for_explicit_yield(&mut self)
pub fn reset_timeslice_for_explicit_yield(&mut self)
Close the current logical-timeslice statistics without selecting a new preemption point. Used when preemption replay reaches a deterministic guest sched_yield boundary.
Sourcepub fn guest_past_first_execve(&self) -> bool
pub fn guest_past_first_execve(&self) -> bool
Are we within the execution of the (first) guest binary or any child processes called by it? Returns false if we are in the very beginning of execution, when the hermit container has forked our process, but we have not yet executed the guest binary. There are few guarantees during this early initialization period, and Detcore should make no assumptions, nor guarantee determinism!
Trait Implementations§
Source§impl<T> AsMut<T> for ThreadState<T>
impl<T> AsMut<T> for ThreadState<T>
Source§impl<T> AsRef<T> for ThreadState<T>
impl<T> AsRef<T> for ThreadState<T>
Source§impl<T: Clone> Clone for ThreadState<T>
impl<T: Clone> Clone for ThreadState<T>
Source§impl<T> Debug for ThreadState<T>
We cannot assume that the record_or_replay “subtool” is Debug, so it is handy to be able to
print the Detcore threadstate alone.
impl<T> Debug for ThreadState<T>
We cannot assume that the record_or_replay “subtool” is Debug, so it is handy to be able to print the Detcore threadstate alone.
Source§impl<T> Default for ThreadState<T>
impl<T> Default for ThreadState<T>
Source§impl<'de, T> Deserialize<'de> for ThreadState<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ThreadState<T>where
T: Deserialize<'de>,
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>,
Auto Trait Implementations§
impl<T> Freeze for ThreadState<T>where
T: Freeze,
impl<T> RefUnwindSafe for ThreadState<T>where
T: RefUnwindSafe,
impl<T> Send for ThreadState<T>where
T: Send,
impl<T> Sync for ThreadState<T>where
T: Sync,
impl<T> Unpin for ThreadState<T>where
T: Unpin,
impl<T> UnsafeUnpin for ThreadState<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ThreadState<T>where
T: UnwindSafe,
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<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.