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

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

            // Don't support this
            if (_kernel.ActiveThread == thread)
            {
                thread.Exit(0);
                _kernel.Schedule();
                Debug.Assert(_kernel.ActiveThread != thread);
            }
            if (thread.State != KThreadState.Dead)
            {
                Log.WriteLine(Verbosity.Critical, Feature.Bios, "sceKernelDeleteThread: thread {0:X} {1} is {2} - it must be dead to delete it properly!", thread.UID, thread.Name, thread.StackBlock);
                return(0);
            }

            Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceKernelDeleteThread: deleting thread {0:X} {1}", thread.UID, thread.Name);

            thread.Delete();
            _kernel.RemoveHandle(thread.UID);

            return(0);
        }
Exemple #2
0
        private void KmoduleStopThreadEnd(int tcsId, int state)
        {
            // Our thread ended - kill it!
            KThread thread = _kernel.GetHandle <KThread>(( uint )state);

            Debug.Assert(thread != null);
            if (thread != null)
            {
                Log.WriteLine(Verbosity.Verbose, Feature.Bios, "ModuleMgrForUser: killing module_stop thread with UID {0:X}", thread.UID);

                thread.Exit(0);
                _kernel.RemoveHandle(thread.UID);

                _kernel.Schedule();

                thread.Delete();
            }
        }