Add a Mutex implementation.
This commit is contained in:
parent
71c6003905
commit
d1b5720abd
2 changed files with 83 additions and 0 deletions
|
|
@ -412,6 +412,36 @@ pub fn reply_port_recv(
|
|||
Ok((num_bytes, num_caps))
|
||||
}
|
||||
|
||||
pub fn mutex_create() -> Result<Capability, ZError> {
|
||||
let mut mutex_cap: z_cap_t = 0;
|
||||
syscall(
|
||||
zion::kZionMutexCreate,
|
||||
&zion::ZMutexCreateReq {
|
||||
mutex_cap: &mut mutex_cap,
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(Capability::take(mutex_cap))
|
||||
}
|
||||
|
||||
pub fn mutex_lock(mutex_cap: &Capability) -> Result<(), ZError> {
|
||||
syscall(
|
||||
zion::kZionMutexLock,
|
||||
&zion::ZMutexLockReq {
|
||||
mutex_cap: mutex_cap.raw(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mutex_release(mutex_cap: &Capability) -> Result<(), ZError> {
|
||||
syscall(
|
||||
zion::kZionMutexRelease,
|
||||
&zion::ZMutexReleaseReq {
|
||||
mutex_cap: mutex_cap.raw(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn semaphore_create() -> Result<Capability, ZError> {
|
||||
let mut sem_cap: z_cap_t = 0;
|
||||
syscall(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue