Pass the reference of sem_buf to semop

This commit is contained in:
Yuke Peng
2024-08-25 15:35:34 +08:00
committed by Tate, Hongliang Tian
parent 83a4366a72
commit 547e6430ee
2 changed files with 4 additions and 4 deletions

View File

@ -166,7 +166,7 @@ impl Semaphore {
);
}
fn sem_op(&self, sem_buf: SemBuf, timeout: Option<Duration>, ctx: &Context) -> Result<()> {
fn sem_op(&self, sem_buf: &SemBuf, timeout: Option<Duration>, ctx: &Context) -> Result<()> {
let mut val = self.val.lock();
let sem_op = sem_buf.sem_op;
let current_pid = ctx.process.pid();
@ -208,7 +208,7 @@ impl Semaphore {
let (waiter, waker) = Waiter::new_pair();
let status = Arc::new(AtomicStatus::new(Status::Pending));
let pending_op = Box::new(PendingOp {
sem_buf,
sem_buf: *sem_buf,
status: status.clone(),
waker: waker.clone(),
process: ctx.posix_thread.weak_process(),
@ -303,7 +303,7 @@ impl Semaphore {
pub fn sem_op(
sem_id: key_t,
sem_buf: SemBuf,
sem_buf: &SemBuf,
timeout: Option<Duration>,
ctx: &Context,
) -> Result<()> {

View File

@ -61,7 +61,7 @@ fn do_sys_semtimedop(
let sem_buf =
CurrentUserSpace::get().read_val::<SemBuf>(tsops + size_of::<SemBuf>() * i)?;
sem_op(sem_id, sem_buf, timeout, ctx)?;
sem_op(sem_id, &sem_buf, timeout, ctx)?;
}
Ok(SyscallReturn::Return(0))