Kernel: Actually wake up the requested number of threads in Semaphore::Release.

Also properly keep track of data in guest memory, this fixes managing the semaphore from userland.

It was found that Semaphores are actually Condition Variables, with Release(1) and Release(-1) being equivalent to notify_one and notify_all. We should change the name of the class to reflect this.
This commit is contained in:
Subv
2018-01-08 14:14:30 -05:00
committed by bunnei
parent 1bbe9309da
commit db3a525166
4 changed files with 18 additions and 21 deletions

View File

@ -13,6 +13,7 @@
namespace Kernel {
// TODO(Subv): This is actually a Condition Variable.
class Semaphore final : public WaitObject {
public:
/**
@ -39,8 +40,9 @@ public:
return HANDLE_TYPE;
}
s32 max_count; ///< Maximum number of simultaneous holders the semaphore can have
s32 available_count; ///< Number of free slots left in the semaphore
s32 GetAvailableCount() const;
void SetAvailableCount(s32 value) const;
std::string name; ///< Name of semaphore (optional)
VAddr guest_addr; ///< Address of the guest semaphore value
VAddr mutex_addr; ///< (optional) Address of guest mutex value associated with this semaphore,
@ -59,9 +61,6 @@ public:
private:
Semaphore();
~Semaphore() override;
/// Updates the state of the object tracking this semaphore in guest memory
void UpdateGuestState();
};
} // namespace Kernel