Task

Trait Task 

Source
pub trait Task {
    // Required method
    fn syscall(&mut self, registers: &mut Registers);

    // Provided methods
    fn page_fault(&mut self, ec: PFErrorCode, cr2: Va) { ... }
    fn access_ok(&self, addr: Range<Va>, is_write: bool) -> bool { ... }
    fn with_page_table_pa(&self, _f: &fn(Pa)) { ... }
}
Expand description

Represents a task executed by a thread.

This trait defines core functionalities required for handling event triggered by user process, such as system calls, page faults.

Required Methods§

Source

fn syscall(&mut self, registers: &mut Registers)

Handles a system call triggered by the user program.

  • The registers parameter contains the state of the CPU registers at the time of the system call.
  • Implementations of this function should parse the system call arguments, execute the corresponding operation, and store the result back in registers.

Provided Methods§

Source

fn page_fault(&mut self, ec: PFErrorCode, cr2: Va)

Handles a page fault that occurs when accessing an unmapped memory page.

  • The ec parameter provides information about the cause of the page fault.
Source

fn access_ok(&self, addr: Range<Va>, is_write: bool) -> bool

Validates a given memory address range before use.

  • addr: The range of virtual addresses being accessed.
  • is_write: Indicates whether the memory is being read (false) or written to (true).
  • Returns true if the memory range is valid, or an appropriate KernelError otherwise.
Source

fn with_page_table_pa(&self, _f: &fn(Pa))

Run a closure with physical address of the page table.

Implementations on Foreign Types§

Source§

impl Task for ()

Source§

fn syscall(&mut self, _registers: &mut Registers)

Implementors§