Struct kernel::procs::Process[][src]

pub struct Process<'a> {
    memory: &'static mut [u8],
    kernel_memory_break: *const u8,
    original_kernel_memory_break: *const u8,
    app_break: *const u8,
    original_app_break: *const u8,
    current_stack_pointer: *const u8,
    original_stack_pointer: *const u8,
    flash: &'static [u8],
    header: TbfHeader,
    stored_regs: StoredRegs,
    yield_pc: usize,
    psr: usize,
    state: State,
    fault_response: FaultResponse,
    mpu_regions: [Cell<(*const u8, PowerOfTwo)>; 5],
    tasks: RingBuffer<'a, Task>,
    pub package_name: &'static str,
    debug: ProcessDebug,


Application memory layout:

    ╒════════ ← memory[memory.len()]
 ╔═ │ Grant
    │   ↓
 D  │ ──────  ← kernel_memory_break
 Y  │
 N  │ ──────  ← app_break
 A  │
 M  │   ↑
    │  Heap
 ╠═ │ ──────  ← app_heap_start
    │  Data
 F  │ ──────  ← data_start_pointer
 I  │ Stack
 X  │   ↓
 E  │
 D  │ ──────  ← current_stack_pointer
 ╚═ ╘════════ ← memory[0]

The process's memory.

Pointer to the end of the allocated (and MPU protected) grant region.

Copy of where the kernel memory break is when the app is first started. This is handy if the app is restarted so we know where to reset the kernel_memory break to without having to recalculate it.

Pointer to the end of process RAM that has been sbrk'd to the process.

Saved when the app switches to the kernel.

Process flash segment. This is the region of nonvolatile flash that the process occupies.

Collection of pointers to the TBF header in flash.

Saved each time the app switches to the kernel.

The PC to jump to when switching back to the app.

Process State Register.

Whether the scheduler can schedule this app.

How to deal with Faults occurring in the process

MPU regions are saved as a pointer-size pair.

size is encoded as X where SIZE = 2(X + 1) and X >= 4.

A null pointer represents an empty region.


The pointer must be aligned to the size. E.g. if the size is 32 bytes, the pointer must be 32-byte aligned.

Essentially a list of callbacks that want to call functions in the process.

Name of the app. Public so that IPC can use it.

Values kept so that we can print useful debug messages when apps fault.


impl<'a> Process<'a>

Reset all grant_ptrs to NULL.

Context switch to the process.

Context switch to the process.

Auto Trait Implementations

impl<'a> !Send for Process<'a>

impl<'a> !Sync for Process<'a>