Skip to main content

Problem:

What is the difference between CBL_THREAD_SLEEP and  CBL_YIELD_RUN_UNIT?

Resolution:

The CBL_YIELD_RUN_UNIT will tell the OS to give the current programs scheduled processing time to another program process so that it can have access to the CPU.  A RUN_UNIT in COBOL is defined as the main programs executable along with any programs that have been loaded by a CALL statement.  This keeps the current program from using all the CPU cycles when it is currently in a wait state.

The CBL_THREAD_SLEEP does basically the same thing but it gives up the current threads processing time and not the entire run-units CPU time.   The difference is that CBL_THREAD_SLEEP might yield it's time to another thread that may be running within the same process (run-unit).  CBL_YIELD_RUN_UNIT yields time on a per process basis and CBL_THREAD_SLEEP yields time on a per thread basis.

Old KB# 7053