Add mutex system call
This commit is contained in:
parent
c957a433c7
commit
50c182293e
@ -1,6 +1,6 @@
|
||||
//! Data structures for process management
|
||||
|
||||
use core::num::NonZeroI32;
|
||||
use core::{num::NonZeroI32, time::Duration};
|
||||
|
||||
use crate::{arch::SavedFrame, impl_place_lifetime, io::RawFd, primitive_enum};
|
||||
|
||||
@ -68,6 +68,31 @@ pub struct SpawnOptions<'a> {
|
||||
pub optional: &'a [SpawnOption],
|
||||
}
|
||||
|
||||
/// Controls how threads are spawned within a process
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct ThreadSpawnOptions {
|
||||
/// Thread entry function
|
||||
pub entry: extern "C" fn(u64) -> !,
|
||||
/// Thread argument value
|
||||
pub argument: u64,
|
||||
/// Thread stack pointer. NOTE: it's the caller's responsibility to allocate a proper stack for
|
||||
/// the thread.
|
||||
pub stack_top: usize,
|
||||
}
|
||||
|
||||
/// Describes a single mutex operation
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub enum MutexOperation {
|
||||
/// Waits on the mutex object until it is different from "compare value"
|
||||
Wait(u32, Option<Duration>),
|
||||
/// Wakes a single mutex-waiting thread
|
||||
Wake,
|
||||
/// Wakes all threads waiting on the mutex
|
||||
WakeAll,
|
||||
}
|
||||
|
||||
// TODO not sure if I really need #[repr(C)] ABI here
|
||||
impl_place_lifetime! {
|
||||
#[doc = "Argument struct passed from the kernel to a spawned process"]
|
||||
|
@ -4,7 +4,7 @@ use crate::primitive_enum;
|
||||
primitive_enum!(
|
||||
#[doc = "Describes a system call issued to the kernel"]
|
||||
pub enum SyscallFunction: usize {
|
||||
#[doc = "Terminate the caller task"]
|
||||
#[doc = "Terminate the caller thread"]
|
||||
Exit = 1,
|
||||
#[doc = "Suspend the caller task for some time"]
|
||||
Nanosleep = 2,
|
||||
@ -49,6 +49,10 @@ primitive_enum!(
|
||||
SetProcessGroupId = 45,
|
||||
#[doc = "Start a new session and set the caller process as its leader"]
|
||||
StartSession = 46,
|
||||
#[doc = "Create and start a new thread within the caller's process"]
|
||||
SpawnThread = 47,
|
||||
#[doc = "Mutex operation: wait, wake, etc."]
|
||||
Mutex = 48,
|
||||
|
||||
#[doc = "Send a signal to a process"]
|
||||
SendSignal = 50,
|
||||
|
Loading…
x
Reference in New Issue
Block a user