fn lock(&self, cxt: &Context) -> Result<&T, KernelError> {
        critical_section(|cs_token| {
            let pi_stack = &mut PiStackGlobal.borrow(cs_token).borrow_mut();
            let curr_tid = cxt.get_tid() as u32;

            let ceiling = self.ceiling;
            let pid_mask = 1 << curr_tid;
            if self.tasks_mask & pid_mask != pid_mask {
                return Err(KernelError::AccessDenied);
            }
            if ceiling as i32 > pi_stack.system_ceiling {
                pi_stack.push_stack(ceiling)?;
                let mask = Self::get_pi_mask(ceiling) & !(1 << curr_tid);
                TaskManager.borrow(cs_token).borrow_mut().block_tasks(mask);
                #[cfg(feature = "system_logger")]
                {
                    if logging::get_resource_lock() {
                        logging::report(LogEventType::ResourceLock(curr_tid));
                    }
                }
                return Ok(&self.inner);
            }
            return Err(KernelError::AccessDenied);
        })
    }
/// Lock the Resource for the currently running task and blocks the competing tasks
Lock the Resource for the currently running task and blocks the competing tasks
Lock the Resource for the currently running task and blocks the competing tasks
fn lock(&self, cxt: &Context) -> Result<&T, KernelError> {
        critical_section(|cs_token| {
            let pi_stack = &mut PiStackGlobal.borrow(cs_token).borrow_mut();
            let curr_tid = cxt.get_tid() as u32;
            let ceiling = self.ceiling;
            let pid_mask = 1 << curr_tid;
            if self.tasks_mask & pid_mask != pid_mask {
                return Err(KernelError::AccessDenied);
            }
            if ceiling as i32 > pi_stack.system_ceiling {
                pi_stack.push_stack(ceiling)?;
                let mask = Self::get_pi_mask(ceiling) & !(1 << curr_tid);
                TaskManager.borrow(cs_token).borrow_mut().block_tasks(mask);
                #[cfg(feature = "system_logger")]
                {
                    if logging::get_resource_lock() {
                        logging::report(LogEventType::ResourceLock(curr_tid));
                    }
                }
                return Ok(&self.inner);
            }
            return Err(KernelError::AccessDenied);
        })
    }
fn lock ( & self , cxt : & Context ) -> Result < & T , KernelError > { critical_section ( | cs_token | { let pi_stack = & mut PiStackGlobal . borrow ( cs_token ) . borrow_mut ( ) ; let curr_tid = cxt . get_tid ( ) as u32 ; let ceiling = self . ceiling ; let pid_mask = 1 << curr_tid ; if self . tasks_mask & pid_mask != pid_mask { return Err ( KernelError :: AccessDenied ) ; } if ceiling as i32 > pi_stack . system_ceiling { pi_stack . push_stack ( ceiling ) ? ; let mask = Self :: get_pi_mask ( ceiling ) & ! ( 1 << curr_tid ) ; TaskManager . borrow ( cs_token ) . borrow_mut ( ) . block_tasks ( mask ) ; # [ cfg ( feature " " ) ] { if logging :: get_resource_lock ( ) { logging :: report ( LogEventType :: ResourceLock ( curr_tid ) ) ; } } return Ok ( & self . inner ) ; } return Err ( KernelError :: AccessDenied ) ; } ) }
Lock the Resource for the currently running task and blocks the competing tasks
Lock the Resource for the currently running task and blocks the competing tasks
&self
cxt
&Context
&self
cxt
&Context