コード例 #1
0
        private HleThread GetThreadById(int ThreadId)
        {
            HleThread HleThread = ThreadManager.GetThreadById(ThreadId);

            if (HleThread == null)
            {
                throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_NOT_FOUND_THREAD));
            }
            return(HleThread);
        }
コード例 #2
0
        private int _sceKernelUnlockLwMutex(SceLwMutexWorkarea *workarea, int count)
        {
            /*xDPx removed this section some resion the unclock function was not included*/
            //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);
        }