pub enum StackSizeClass {
Small,
Medium,
Big,
}Expand description
Stack-size class — epicsThreadStackSizeClass (epicsThread.h:91).
The byte size is implementation-dependent in C. These mirror the POSIX
table STACK_SIZE(f) = f * 0x10000 * sizeof(void*)
(libcom/src/osi/os/posix/osdThread.c:506-509), pointer-width
parameterised exactly as the C macro is: Small = 1, Medium = 2, Big = 4
units of 0x10000 * sizeof(void*). On a 64-bit host that is
512 KiB / 1 MiB / 2 MiB; on armv7-rtems-eabihf it is
256 KiB / 512 KiB / 1 MiB.
§This is the table a C IOC on RTEMS 6 uses too
Base has a second, much smaller table — 5000 / 8000 / 11000 bytes, floored
at RTEMS_MINIMUM_STACK_SIZE — in os/RTEMS-score/osdThread.c:136-150.
It does not apply here. configure/toolchain.c:29-35 selects
OS_API = posix for __RTEMS_MAJOR__ >= 5, so an RTEMS 6 build searches
os/RTEMS-posix then os/RTEMS, neither of which contains an
osdThread.c, and lands on os/posix/osdThread.c — the file above. The
score table is what RTEMS 4/5 used.
Do not “align” these constants with 5000/8000/11000. That would be a
regression against the C IOC we are matching, not a correction: on RTEMS 6
the C IOC asks pthread_attr_setstacksize for the POSIX number
(os/posix/osdThread.c:212-215), which is the same call std makes for
us, with the same argument.
Variants§
Implementations§
Source§impl StackSizeClass
impl StackSizeClass
Sourcepub fn bytes(self) -> usize
pub fn bytes(self) -> usize
Stack size in bytes for this class, matching the POSIX
stackSizeTable in osdThread.c on every target.
C’s STACK_SIZE(f) = f * 0x10000 * sizeof(void*) is parameterised by
pointer width and so is this, so the two agree by construction rather
than on one word size: 512 KiB / 1 MiB / 2 MiB on a 64-bit host, and
256 KiB / 512 KiB / 1 MiB on armv7-rtems-eabihf — which is exactly
what a C IOC asks pthread_attr_setstacksize for on that target.
Read “on a 64-bit target” here before: it was wrong in the direction
that matters, because it invited a reader to assume the RTEMS numbers
were unverified. This crate is portable to 64-bit embedded targets
too — x86_64-wrs-vxworks — and pays for it: a 64-bit pointer doubles
every class in this table, so an x86_64-wrs-vxworks CA client thread
costs exactly 2× what the same thread costs on armv7-rtems-eabihf,
pointer width for pointer width, not a difference in the formula.
Trait Implementations§
Source§impl Clone for StackSizeClass
impl Clone for StackSizeClass
Source§fn clone(&self) -> StackSizeClass
fn clone(&self) -> StackSizeClass
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more