Struct kernel::syscall::SystemCall

source ·
pub struct SystemCall<'a> {
    thread: &'a Thread,
}
Expand description

The SystemCall struct provides an interface for invoking system calls on a given thread.

Fields§

§thread: &'a Thread

Implementations§

source§

impl SystemCall<'_>

source

pub async fn sys_read( &self, fd: usize, buffer: UserPtr<u8>, _length: usize ) -> (isize, ControlFlow)

Reads the content from a file descriptor and writes them to a buffer.

source

pub fn sys_write( &self, fd: usize, buffer: UserPtr<u8>, length: usize ) -> (isize, ControlFlow)

Writes the contents of a buffer to a file descriptor.

source§

impl SystemCall<'_>

source

pub fn sys_exit(&self, exit_code: usize) -> (isize, ControlFlow)

Terminates the current thread with the given exit code.

source

pub fn sys_sched_yield(&self) -> (isize, ControlFlow)

Yields the CPU to another thread.

source

pub fn sys_fork(&self) -> (isize, ControlFlow)

Forks the current process and create a new child process.

source

pub async fn sys_waitpid( &self, pid: isize, wait_status: UserPtr<usize> ) -> (isize, ControlFlow)

Waits for a child process with the given process to terminate, and return the PID and exit.

source

pub fn sys_exec(&self, path: UserPtr<u8>) -> (isize, ControlFlow)

Replaces the current process with a new process loaded from the executable file with a given name.

source§

impl SystemCall<'_>

source

pub fn sys_get_time(&self) -> (isize, ControlFlow)

Returns the current system time in milliseconds.

source§

impl<'a> SystemCall<'a>

source

pub fn new(thread: &'a Thread) -> Self

Constructs a new SystemCall instance with the given thread.

source

pub async fn execute(&mut self) -> ControlFlow

Invokes a system call with the given arguments.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SystemCall<'a>

§

impl<'a> Send for SystemCall<'a>

§

impl<'a> Sync for SystemCall<'a>

§

impl<'a> Unpin for SystemCall<'a>

§

impl<'a> !UnwindSafe for SystemCall<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.