public int sceKernelLockLwMutex(SceLwMutexWorkarea* WorkAreaPointer, int Count, int* TimeOut) { return _sceKernelLockLwMutexCB(WorkAreaPointer, Count, TimeOut, HandleCallbacks: false); }
private int _sceKernelUnlockLwMutex(SceLwMutexWorkarea* workarea, int count) { return 0; if (workarea->uid == -1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_NOT_FOUND)); } if (count <= 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if ((workarea->attr & ThreadManForUser.MutexAttributesEnum.AllowRecursive) == 0 && count > 1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (workarea->lockLevel == 0 || workarea->lockThread != HleThreadManager.Current.Id) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_UNLOCKED)); } if (workarea->lockLevel < count) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_UNLOCK_UNDERFLOW)); } workarea->lockLevel -= count; if (workarea->lockLevel == 0) { HleThreadManager.GetThreadById(workarea->lockThread).WakeUpAndReschedule(); } return 0; }
private int _sceKernelLockLwMutexCB(SceLwMutexWorkarea* workarea, int count, int* TimeOut, bool HandleCallbacks) { #if false if (count <= 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); if (count > 1 && workarea->attr.HasFlagGeneric(ThreadManForUser.MutexAttributesEnum.AllowRecursive)) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); if (count + workarea->lockLevel < 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_LOCK_OVERFLOW)); if (workarea->uid == -1) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_NOT_FOUND)); if (workarea->lockLevel == 0) { if (workarea->lockThread != 0) { // Validate that it actually exists so we can return an error if not. kernelObjects.Get<LwMutex>(workarea->uid, error); if (error) return false; } workarea->lockLevel = count; workarea->lockThread = __KernelGetCurThread(); return true; } if (workarea->lockThread == __KernelGetCurThread()) { // Recursive mutex, let's just increase the lock count and keep going if (workarea->attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) { workarea->lockLevel += count; return true; } else { error = PSP_LWMUTEX_ERROR_ALREADY_LOCKED; return false; } } #endif return 0; }
private int _sceKernelTryLockLwMutex(SceLwMutexWorkarea* WorkAreaPointer, int Count) { return 0; }
public int sceKernelUnlockLwMutex(SceLwMutexWorkarea* WorkAreaPointer, int Count) { return _sceKernelUnlockLwMutex(WorkAreaPointer, Count); }