// SDK location: /user/pspthreadman.h:264
        // SDK declaration: int sceKernelWakeupThread(SceUID thid);
        public int sceKernelWakeupThread(int thid)
        {
            KThread thread = _kernel.GetHandle <KThread>(thid);

            if (thread == null)
            {
                return(-1);
            }

            // Perhaps we shouldn't schedule here?
            thread.Wake(0);
            if (thread.State == KThreadState.Ready)
            {
                _kernel.Schedule();
            }

            return(0);
        }
        // SDK location: /user/pspthreadman.h:876
        // SDK declaration: int sceKernelCancelReceiveMbx(SceUID mbxid, int *pnum);
        public int sceKernelCancelReceiveMbx(int mbxid, int pnum)
        {
            KMessageBox box = _kernel.GetHandle <KMessageBox>(mbxid);

            if (box == null)
            {
                return(unchecked ((int)0x8002019B));
            }

            unsafe
            {
                *(int *)_kernel.MemorySystem.Translate((uint)pnum) = box.WaitingThreads.Count;
            }

            while (box.WaitingThreads.Count > 0)
            {
                KThread thread = box.WaitingThreads.Dequeue();
                thread.Wake(unchecked ((int)0x800201a9));                // SCE_KERNEL_ERROR_WAIT_CANCEL
            }

            return(0);
        }