summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-12-04 17:55:13 +0100
committerSubv <subv2112@gmail.com>2014-12-13 19:40:12 +0100
commitabff4a7ee23a04baa9d264417c9c814309ef294b (patch)
tree399521b0c74e6cc33957feec459f6682be81a978 /src
parentSVC: Implemented ReleaseSemaphore. (diff)
downloadyuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.gz
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.bz2
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.lz
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.xz
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.zst
yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/semaphore.cpp8
-rw-r--r--src/core/hle/kernel/semaphore.h4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp
index 674b727d5..c5c1fbeb3 100644
--- a/src/core/hle/kernel/semaphore.cpp
+++ b/src/core/hle/kernel/semaphore.cpp
@@ -20,7 +20,7 @@ public:
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Semaphore; }
Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::Semaphore; }
- u32 initial_count; ///< Number of reserved entries TODO(Subv): Make use of this
+ u32 initial_count; ///< Number of entries reserved for other threads
u32 max_count; ///< Maximum number of simultaneous holders the semaphore can have
u32 current_usage; ///< Number of currently used entries in the semaphore
std::queue<Handle> waiting_threads; ///< Threads that are waiting for the semaphore
@@ -58,7 +58,7 @@ public:
/**
* Creates a semaphore
* @param handle Reference to handle for the newly created semaphore
- * @param initial_count initial amount of times the semaphore is held
+ * @param initial_count number of slots reserved for other threads
* @param max_count maximum number of holders the semaphore can have
* @param name Optional name of semaphore
* @return Pointer to new Semaphore object
@@ -70,8 +70,10 @@ Semaphore* CreateSemaphore(Handle& handle, u32 initial_count,
handle = g_object_pool.Create(semaphore);
semaphore->initial_count = initial_count;
- // When the semaphore is created, all slots are used by the creator thread
+ // When the semaphore is created, some slots are reserved for other threads,
+ // and the rest is reserved for the caller thread
semaphore->max_count = semaphore->current_usage = max_count;
+ semaphore->current_usage -= initial_count;
semaphore->name = name;
return semaphore;
diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h
index 854831ecf..b29812e1d 100644
--- a/src/core/hle/kernel/semaphore.h
+++ b/src/core/hle/kernel/semaphore.h
@@ -13,8 +13,8 @@ namespace Kernel {
/**
* Creates a semaphore
* @param handle Pointer to the handle of the newly created object
- * @param initial_count number of reserved entries in the semaphore
- * @param max_count maximum number of holders the semaphore can have
+ * @param initial_count number of slots reserved for other threads
+ * @param max_count maximum number of slots the semaphore can have
* @param name Optional name of semaphore
* @return ResultCode of the error
*/