ResultVal<s32> Semaphore::Release(s32 release_count) { if (max_count - available_count < release_count) return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); s32 previous_count = available_count; available_count += release_count; // Notify some of the threads that the semaphore has been released // stop once the semaphore is full again or there are no more waiting threads while (!ShouldWait() && WakeupNextThread() != nullptr) { Acquire(); } return MakeResult<s32>(previous_count); }
void Thread::Acquire() { ASSERT_MSG(!ShouldWait(), "object unavailable!"); }
void Event::Acquire(Thread* thread) { ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); if (reset_type == ResetType::OneShot) signaled = false; }
void Semaphore::Acquire() { ASSERT_MSG(!ShouldWait(), "object unavailable!"); --available_count; }
void ServerPort::Acquire(Thread* thread) { ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); }
void ServerPort::Acquire() { ASSERT_MSG(!ShouldWait(), "object unavailable!"); }
void Timer::Acquire() { ASSERT_MSG(!ShouldWait(), "object unavailable!"); if (reset_type == ResetType::OneShot) signaled = false; }
void Acquire() override { _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); --available_count; }