Exemple #1
0
 public virtual void onThreadDeleted(SceKernelThreadInfo thread)
 {
     if (thread.isWaitingForType(PSP_WAIT_MBX))
     {
         removeWaitingThread(thread);
     }
 }
Exemple #2
0
        public virtual SceKernelThreadInfo getNextWaitingThread(SceKernelThreadInfo baseThread)
        {
            if (baseThread == null)
            {
                return(FirstWaitingThread);
            }

            int index = waitingThreads.IndexOf(baseThread.uid);

            if (index < 0 || (index + 1) >= NumWaitingThreads)
            {
                return(null);
            }

            int uid = waitingThreads[index + 1];
            SceKernelThreadInfo thread = Modules.ThreadManForUserModule.getThreadById(uid);

            // Is the thread still existing
            if (thread == null)
            {
                // Thread is no longer existing, delete it from the waiting list and retry
                waitingThreads.RemoveAt(index + 1);
                return(getNextWaitingThread(baseThread));
            }

            // Is the thread still waiting on this ID?
            if (!thread.isWaitingForType(waitType) || thread.waitId != waitId)
            {
                // The thread is no longer waiting on this object, remove it from the waiting list and retry
                waitingThreads.RemoveAt(index + 1);
                return(getNextWaitingThread(baseThread));
            }

            return(thread);
        }
Exemple #3
0
 public virtual void onThreadDeleted(SceKernelThreadInfo thread)
 {
     if (thread.isWaitingForType(PSP_WAIT_LWMUTEX))
     {
         // decrement numWaitThreads
         removeWaitingThread(thread);
     }
 }
Exemple #4
0
 public virtual void onThreadDeleted(SceKernelThreadInfo thread)
 {
     if (thread.isWaitingForType(PSP_WAIT_MUTEX))
     {
         // decrement numWaitThreads
         removeWaitingThread(thread);
     }
     foreach (SceKernelMutexInfo info in mutexMap.Values)
     {
         if (info.threadid == thread.uid)
         {
             Console.WriteLine(string.Format("onThreadDeleted: thread {0} owning mutex {1}", thread, info));
         }
     }
 }
Exemple #5
0
        public virtual int hleKernelSignalSema(SceKernelSemaInfo sema, int signal)
        {
            // Check that currentCount will not exceed the maxCount
            // after releasing all the threads waiting on this sema.
            int newCount = sema.currentCount + signal;

            if (newCount > sema.maxCount)
            {
                for (IEnumerator <SceKernelThreadInfo> it = Modules.ThreadManForUserModule.GetEnumerator(); it.MoveNext();)
                {
                    SceKernelThreadInfo thread = it.Current;
                    if (thread.isWaitingForType(PSP_WAIT_SEMA) && thread.wait.Semaphore_id == sema.uid)
                    {
                        newCount -= thread.wait.Semaphore_signal;
                    }
                }
                if (newCount > sema.maxCount)
                {
                    //if (log.DebugEnabled)
                    {
                        Console.WriteLine(string.Format("hleKernelSignalSema returning 0x{0:X8}(ERROR_KERNEL_SEMA_OVERFLOW)", ERROR_KERNEL_SEMA_OVERFLOW));
                    }
                    return(ERROR_KERNEL_SEMA_OVERFLOW);
                }
            }

            sema.currentCount += signal;

            onSemaphoreModified(sema);

            // Sanity check...
            if (sema.currentCount > sema.maxCount)
            {
                // This situation should never happen, otherwise something went wrong
                // in the overflow check above.
                Console.WriteLine(string.Format("hleKernelSignalSema currentCount {0:D} exceeding maxCount {1:D}", sema.currentCount, sema.maxCount));
            }

            //if (log.DebugEnabled)
            {
                Console.WriteLine(string.Format("hleKernelSignalSema returning 0, {0}", sema));
            }

            return(0);
        }