Process

Struct Process 

Source
pub struct Process {
    pub file_struct: FileStruct,
}
Expand description

A process state of project 1, which contains file state.

Fields§

§file_struct: FileStruct

Trait Implementations§

Source§

impl Default for Process

Source§

fn default() -> Process

Returns the “default value” for a type. Read more
Source§

impl Task for Process

Source§

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

Handles a system call request from a user program.

This function is the entry point for system call handling. It retrieves the system call ABI from the provided Registers structure, which includes the system call number and its arguments. Based on the system call number (sysno), it looks up the appropriate handler function in a predefined list. If a handler is found, it is invoked with the ABI, otherwise, an error (KernelError::NoSuchSyscall) is returned.

After the handler function processes the system call, the return value (either a success or error) is set back into the CPU registers via the set_return_value method. The return value is stored in the %rax register as per the x86-64 system call convention.

§Parameters
  • regs: A mutable reference to the Registers struct, which contains the current state of the CPU registers. This structure will be used to retrieve the system call number and its arguments, and also to set the return value.
§Functionality

The function processes the system call as follows:

  1. Extracts the system call number and arguments using the SyscallAbi::from_registers.
  2. Looks up the corresponding handler function from a predefined list of system calls. The handler function is selected based on the system call number (sysno).
  3. If a handler is found, it is executed with the ABI as an argument. If no handler is found, the function returns a KernelError::NoSuchSyscall error.

The result of the system call handler (either success or error) is then returned via the SyscallAbi::set_return_value method, which modifies the CPU registers accordingly.

Source§

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

Handles a page fault that occurs when accessing an unmapped memory page. Read more
Source§

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

Validates a given memory address range before use. Read more
Source§

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

Run a closure with physical address of the page table.

Auto Trait Implementations§

§

impl Freeze for Process

§

impl !RefUnwindSafe for Process

§

impl Send for Process

§

impl Sync for Process

§

impl Unpin for Process

§

impl !UnwindSafe for Process

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.