diff options
| author | 2014-12-04 11:55:13 -0500 | |
|---|---|---|
| committer | 2014-12-13 13:40:12 -0500 | |
| commit | abff4a7ee23a04baa9d264417c9c814309ef294b (patch) | |
| tree | 399521b0c74e6cc33957feec459f6682be81a978 /src | |
| parent | SVC: Implemented ReleaseSemaphore. (diff) | |
| download | yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.gz yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.tar.xz yuzu-abff4a7ee23a04baa9d264417c9c814309ef294b.zip | |
Semaphore: Implemented the initial_count parameter.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/semaphore.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/semaphore.h | 4 |
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: | |||
| 20 | static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Semaphore; } | 20 | static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Semaphore; } |
| 21 | Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::Semaphore; } | 21 | Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::Semaphore; } |
| 22 | 22 | ||
| 23 | u32 initial_count; ///< Number of reserved entries TODO(Subv): Make use of this | 23 | u32 initial_count; ///< Number of entries reserved for other threads |
| 24 | u32 max_count; ///< Maximum number of simultaneous holders the semaphore can have | 24 | u32 max_count; ///< Maximum number of simultaneous holders the semaphore can have |
| 25 | u32 current_usage; ///< Number of currently used entries in the semaphore | 25 | u32 current_usage; ///< Number of currently used entries in the semaphore |
| 26 | std::queue<Handle> waiting_threads; ///< Threads that are waiting for the semaphore | 26 | std::queue<Handle> waiting_threads; ///< Threads that are waiting for the semaphore |
| @@ -58,7 +58,7 @@ public: | |||
| 58 | /** | 58 | /** |
| 59 | * Creates a semaphore | 59 | * Creates a semaphore |
| 60 | * @param handle Reference to handle for the newly created semaphore | 60 | * @param handle Reference to handle for the newly created semaphore |
| 61 | * @param initial_count initial amount of times the semaphore is held | 61 | * @param initial_count number of slots reserved for other threads |
| 62 | * @param max_count maximum number of holders the semaphore can have | 62 | * @param max_count maximum number of holders the semaphore can have |
| 63 | * @param name Optional name of semaphore | 63 | * @param name Optional name of semaphore |
| 64 | * @return Pointer to new Semaphore object | 64 | * @return Pointer to new Semaphore object |
| @@ -70,8 +70,10 @@ Semaphore* CreateSemaphore(Handle& handle, u32 initial_count, | |||
| 70 | handle = g_object_pool.Create(semaphore); | 70 | handle = g_object_pool.Create(semaphore); |
| 71 | 71 | ||
| 72 | semaphore->initial_count = initial_count; | 72 | semaphore->initial_count = initial_count; |
| 73 | // When the semaphore is created, all slots are used by the creator thread | 73 | // When the semaphore is created, some slots are reserved for other threads, |
| 74 | // and the rest is reserved for the caller thread | ||
| 74 | semaphore->max_count = semaphore->current_usage = max_count; | 75 | semaphore->max_count = semaphore->current_usage = max_count; |
| 76 | semaphore->current_usage -= initial_count; | ||
| 75 | semaphore->name = name; | 77 | semaphore->name = name; |
| 76 | 78 | ||
| 77 | return semaphore; | 79 | 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 { | |||
| 13 | /** | 13 | /** |
| 14 | * Creates a semaphore | 14 | * Creates a semaphore |
| 15 | * @param handle Pointer to the handle of the newly created object | 15 | * @param handle Pointer to the handle of the newly created object |
| 16 | * @param initial_count number of reserved entries in the semaphore | 16 | * @param initial_count number of slots reserved for other threads |
| 17 | * @param max_count maximum number of holders the semaphore can have | 17 | * @param max_count maximum number of slots the semaphore can have |
| 18 | * @param name Optional name of semaphore | 18 | * @param name Optional name of semaphore |
| 19 | * @return ResultCode of the error | 19 | * @return ResultCode of the error |
| 20 | */ | 20 | */ |