Error No Yield Performed 721 (0x2D1): Fix it With 4 Steps

Adjust your code and check the thread priority properly to fix this

Reading time icon 2 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

ERROR_NO_YIELD_PERFORMED often affects developers and it can cause issues in your code, so let’s see how we can fix this problem.

How can I fix ERROR_NO_YIELD_PERFORMED?

1. Check thread priority

  1. Open your code.
  2. If you’re working with Windows API, modify the thread priority like this: SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
  3. Replace THREAD_PRIORITY_NORMAL with THREAD_PRIORITY_ABOVE_NORMAL if needed.

2.  Avoid using unnecessary sleep calls

  1. Open your code.
  2. Replace any occurrences of Sleep(0); with Sleep(1);
  3. Use SwitchToThread() only when needed like this:
    if (!SwitchToThread()) {
        Sleep(1);  // Fallback if no threads are waiting
    }

    switchtothread
  4. Recompile and test if the problem is resolved.

3. Verify thread availability

  1. Open the code.
  2. If you’re using a thread pool in C++ check if the pool is not exhausted with the following: std::thread::hardware_concurrency();
  3. Lastly, test if more threads resolve the issue.

4. Other tips to try

  1. Ensure that your drivers and system are up to date.
  2. Check the system usage with Task Manager. If resources are low, you might need to close unnecessary apps, optimize the code, or improve your hardware.
  3. Use Process Explorer to analyze blocked or stuck threads.
  4. Use Windows Performance Analyzer to record a trace and analyze CPU scheduling.
  5. Use GetLastError() to log the error and capture more details.

ERROR_NO_YIELD_PERFORMED can often be recognized by 721 (0x2D1) A yield execution was performed and no thread was available to run message, so keep an eye out for it.

This isn’t the only thread error you can encounter, and we have great guides on ERROR_THREAD_NOT_IN_PROCESS and ERROR_TOO_MANY_THREADS that might help you, so feel free to visit them.

More about the topics: error, Windows 11 Fix

User forum

0 messages