Kernel: Remove unused ConditionVariable class.
This commit is contained in:
parent
5fdfbfe25a
commit
be155f4d9d
|
@ -42,8 +42,6 @@ add_library(core STATIC
|
||||||
hle/kernel/client_port.h
|
hle/kernel/client_port.h
|
||||||
hle/kernel/client_session.cpp
|
hle/kernel/client_session.cpp
|
||||||
hle/kernel/client_session.h
|
hle/kernel/client_session.h
|
||||||
hle/kernel/condition_variable.cpp
|
|
||||||
hle/kernel/condition_variable.h
|
|
||||||
hle/kernel/errors.h
|
hle/kernel/errors.h
|
||||||
hle/kernel/event.cpp
|
hle/kernel/event.cpp
|
||||||
hle/kernel/event.h
|
hle/kernel/event.h
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "core/hle/kernel/condition_variable.h"
|
|
||||||
#include "core/hle/kernel/errors.h"
|
|
||||||
#include "core/hle/kernel/kernel.h"
|
|
||||||
#include "core/hle/kernel/object_address_table.h"
|
|
||||||
#include "core/hle/kernel/thread.h"
|
|
||||||
|
|
||||||
namespace Kernel {
|
|
||||||
|
|
||||||
ConditionVariable::ConditionVariable() {}
|
|
||||||
ConditionVariable::~ConditionVariable() {}
|
|
||||||
|
|
||||||
ResultVal<SharedPtr<ConditionVariable>> ConditionVariable::Create(VAddr guest_addr,
|
|
||||||
std::string name) {
|
|
||||||
SharedPtr<ConditionVariable> condition_variable(new ConditionVariable);
|
|
||||||
|
|
||||||
condition_variable->name = std::move(name);
|
|
||||||
condition_variable->guest_addr = guest_addr;
|
|
||||||
condition_variable->mutex_addr = 0;
|
|
||||||
|
|
||||||
// Condition variables are referenced by guest address, so track this in the kernel
|
|
||||||
g_object_address_table.Insert(guest_addr, condition_variable);
|
|
||||||
|
|
||||||
return MakeResult<SharedPtr<ConditionVariable>>(std::move(condition_variable));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConditionVariable::ShouldWait(Thread* thread) const {
|
|
||||||
return GetAvailableCount() <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConditionVariable::Acquire(Thread* thread) {
|
|
||||||
if (GetAvailableCount() <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetAvailableCount(GetAvailableCount() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultCode ConditionVariable::Release(s32 target) {
|
|
||||||
if (target == -1) {
|
|
||||||
// When -1, wake up all waiting threads
|
|
||||||
SetAvailableCount(static_cast<s32>(GetWaitingThreads().size()));
|
|
||||||
WakeupAllWaitingThreads();
|
|
||||||
} else {
|
|
||||||
// Otherwise, wake up just a single thread
|
|
||||||
SetAvailableCount(target);
|
|
||||||
WakeupWaitingThread(GetHighestPriorityReadyThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 ConditionVariable::GetAvailableCount() const {
|
|
||||||
return Memory::Read32(guest_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConditionVariable::SetAvailableCount(s32 value) const {
|
|
||||||
Memory::Write32(guest_addr, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Kernel
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <queue>
|
|
||||||
#include "common/common_types.h"
|
|
||||||
#include "core/hle/kernel/kernel.h"
|
|
||||||
#include "core/hle/kernel/wait_object.h"
|
|
||||||
#include "core/hle/result.h"
|
|
||||||
|
|
||||||
namespace Kernel {
|
|
||||||
|
|
||||||
class ConditionVariable final : public WaitObject {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Creates a condition variable.
|
|
||||||
* @param guest_addr Address of the object tracking the condition variable in guest memory. If
|
|
||||||
* specified, this condition variable will update the guest object when its state changes.
|
|
||||||
* @param name Optional name of condition variable.
|
|
||||||
* @return The created condition variable.
|
|
||||||
*/
|
|
||||||
static ResultVal<SharedPtr<ConditionVariable>> Create(VAddr guest_addr,
|
|
||||||
std::string name = "Unknown");
|
|
||||||
|
|
||||||
std::string GetTypeName() const override {
|
|
||||||
return "ConditionVariable";
|
|
||||||
}
|
|
||||||
std::string GetName() const override {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const HandleType HANDLE_TYPE = HandleType::ConditionVariable;
|
|
||||||
HandleType GetHandleType() const override {
|
|
||||||
return HANDLE_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 GetAvailableCount() const;
|
|
||||||
void SetAvailableCount(s32 value) const;
|
|
||||||
|
|
||||||
std::string name; ///< Name of condition variable (optional)
|
|
||||||
VAddr guest_addr; ///< Address of the guest condition variable value
|
|
||||||
VAddr mutex_addr; ///< (optional) Address of guest mutex value associated with this condition
|
|
||||||
///< variable, used for implementing events
|
|
||||||
|
|
||||||
bool ShouldWait(Thread* thread) const override;
|
|
||||||
void Acquire(Thread* thread) override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Releases a slot from a condition variable.
|
|
||||||
* @param target The number of threads to wakeup, -1 is all.
|
|
||||||
* @return ResultCode indicating if the operation succeeded.
|
|
||||||
*/
|
|
||||||
ResultCode Release(s32 target);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ConditionVariable();
|
|
||||||
~ConditionVariable() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Kernel
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
#include "core/hle/kernel/client_port.h"
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/kernel/condition_variable.h"
|
|
||||||
#include "core/hle/kernel/event.h"
|
#include "core/hle/kernel/event.h"
|
||||||
#include "core/hle/kernel/handle_table.h"
|
#include "core/hle/kernel/handle_table.h"
|
||||||
#include "core/hle/kernel/mutex.h"
|
#include "core/hle/kernel/mutex.h"
|
||||||
|
@ -394,11 +393,6 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->SetPriority(priority);
|
thread->SetPriority(priority);
|
||||||
thread->UpdatePriority();
|
|
||||||
|
|
||||||
// Update the mutexes that this thread is waiting for
|
|
||||||
for (auto& mutex : thread->pending_mutexes)
|
|
||||||
mutex->UpdatePriority();
|
|
||||||
|
|
||||||
Core::System::GetInstance().PrepareReschedule();
|
Core::System::GetInstance().PrepareReschedule();
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
|
|
|
@ -329,15 +329,6 @@ void Thread::SetPriority(u32 priority) {
|
||||||
nominal_priority = current_priority = priority;
|
nominal_priority = current_priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::UpdatePriority() {
|
|
||||||
u32 best_priority = nominal_priority;
|
|
||||||
for (auto& mutex : held_mutexes) {
|
|
||||||
if (mutex->priority < best_priority)
|
|
||||||
best_priority = mutex->priority;
|
|
||||||
}
|
|
||||||
BoostPriority(best_priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::BoostPriority(u32 priority) {
|
void Thread::BoostPriority(u32 priority) {
|
||||||
Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority);
|
Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority);
|
||||||
current_priority = priority;
|
current_priority = priority;
|
||||||
|
|
|
@ -103,12 +103,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetPriority(u32 priority);
|
void SetPriority(u32 priority);
|
||||||
|
|
||||||
/**
|
|
||||||
* Boost's a thread's priority to the best priority among the thread's held mutexes.
|
|
||||||
* This prevents priority inversion via priority inheritance.
|
|
||||||
*/
|
|
||||||
void UpdatePriority();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporarily boosts the thread's priority until the next time it is scheduled
|
* Temporarily boosts the thread's priority until the next time it is scheduled
|
||||||
* @param priority The new priority
|
* @param priority The new priority
|
||||||
|
|
Reference in New Issue