pub struct LoadedImage { /* private fields */ }Expand description
An installed image. The input ELF bytes may be discarded after loading.
Implementations§
Source§impl LoadedImage
impl LoadedImage
Sourcepub unsafe fn spawn<T: 'static>(
self,
manager: &'static Manager,
parent: TaskIdentifier,
name: &str,
stack: Stack,
startup: Startup,
map: impl FnOnce(i32) -> T + 'static,
) -> Result<impl Future<Output = Result<(JoinHandle<T>, TaskIdentifier)>>, Error>
pub unsafe fn spawn<T: 'static>( self, manager: &'static Manager, parent: TaskIdentifier, name: &str, stack: Stack, startup: Startup, map: impl FnOnce(i32) -> T + 'static, ) -> Result<impl Future<Output = Result<(JoinHandle<T>, TaskIdentifier)>>, Error>
Prepare to run the ELF entry point on the calling task’s executor.
Allocating the process state can fail with Error::AllocationFailed,
which releases the image, the arguments and the streams. Otherwise the returned
future spawns the task and resolves to its join handle and identifier, like
stackful::spawn_with_result.
The image, the process heap and the host state are released when the task finishes or is cancelled, or when the future is dropped before it completes. So is everything the program holds. A program that returns, exits or is cancelled has its arguments, its startup streams and its graphics objects released, and so are the files, directories, listings, children and sockets it opened and did not close. A cancelled program is a task future that is dropped while its coroutine is suspended: its coroutine stack is freed, with no destructor run on it.
§Safety
The image must come from a trusted source and implement
int32_t _xila_start(const XilaStartup *). Its entry and callees must
obey the startup lifetime rules, fit on the stack, and return without
unwinding or leaving code or data references in other tasks. The caller
must meet the executor affinity and single-core requirements of
stackful::spawn.
Sourcepub unsafe fn start(
self,
stack: Stack,
startup: Startup,
) -> Result<impl Future<Output = i32> + 'static, Error>
pub unsafe fn start( self, stack: Stack, startup: Startup, ) -> Result<impl Future<Output = i32> + 'static, Error>
Run the ELF entry point on the calling task, as a future that resolves to its exit status, without spawning a task for it.
Dropping the future before it completes cancels the program, as dropping the task
future of LoadedImage::spawn does: its coroutine stack is freed, and everything
it held is released. The program runs inside the task that polls the future, which is
how a process learns its identity.
§Safety
Same as LoadedImage::spawn; the future must be polled on the executor that
created it.
Source§impl LoadedImage
impl LoadedImage
Sourcepub fn load(
bytes: &[u8],
memory: &'static dyn ExecutableMemory,
max_image_size: usize,
) -> Result<Self, Error>
pub fn load( bytes: &[u8], memory: &'static dyn ExecutableMemory, max_image_size: usize, ) -> Result<Self, Error>
Validate, copy and relocate the ELF. Reject images whose full virtual span (including gaps and BSS) exceeds the caller’s memory budget.