mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-22 19:40:05 +00:00
Finished primary work on semaphores, implemented mutexing
This commit is contained in:
parent
06c041fa79
commit
69769d4010
@ -34,7 +34,13 @@ public:
|
||||
*/
|
||||
Result SyncRequest(bool* wait) {
|
||||
// TODO(bunnei): ImplementMe
|
||||
if (!locked) {
|
||||
locked = true;
|
||||
*wait = false;
|
||||
}
|
||||
else {
|
||||
*wait = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,13 @@ public:
|
||||
*/
|
||||
Result SyncRequest(bool* wait) {
|
||||
// TODO(bravia): ImplementMe
|
||||
if (count > 0) {
|
||||
count--;
|
||||
*wait = false;
|
||||
}
|
||||
else{
|
||||
*wait = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -43,7 +50,10 @@ public:
|
||||
* @return Result of operation, 0 on success, otherwise error code
|
||||
*/
|
||||
Result WaitSynchronization(bool* wait) {
|
||||
// TODO(bravia): ImplementMe
|
||||
*wait = (count == 0);
|
||||
if (count == 0) {
|
||||
Kernel::WaitCurrentThread(WAITTYPE_SEMA);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@ -52,17 +62,22 @@ public:
|
||||
|
||||
/**
|
||||
* Releases a semaphore
|
||||
* @param unknown
|
||||
* @param the previous count
|
||||
* @param handle Handle to mutex to release
|
||||
* @param unknown
|
||||
* @param the number of increments to be made
|
||||
*/
|
||||
Result ReleaseSemaphore(s32 * count, Handle handle, s32 release_count) {
|
||||
Semaphore* sem = Kernel::g_object_pool.GetFast<Semaphore>(handle);
|
||||
|
||||
_assert_msg_(KERNEL, (sem != nullptr), "ReleaseSemaphore tried to release a nullptr sem!");
|
||||
|
||||
//TODO(bravia): ImplementMe
|
||||
*count = sem->count;
|
||||
if (sem->count + release_count <= sem->max_count) {
|
||||
sem->count += release_count;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,7 +284,7 @@ Result CreateSemaphore(Handle* sem, s32 initial_count, s32 max_count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Release a mutex
|
||||
/// Release a Semaphore
|
||||
Result ReleaseSemaphore(s32* count, Handle handle, s32 releaseCount) {
|
||||
DEBUG_LOG(SVC, "called handle=0x%08X", handle);
|
||||
_assert_msg_(KERNEL, (handle != 0), "called, but handle is nullptr!");
|
||||
|
Loading…
Reference in New Issue
Block a user