DevHelp Yield

This service yields the CPU to a scheduled thread of equal, or higher, priority.

C
USHORT APIENTRY DevHelp_Yield

Assembler
 MOV  DL,DevHlp_Yield

CALL [Device_Help] 

C
None.

Assembler
None.

C
Success Indicator: None.

Possible errors: None.

Assembler
None.

Remarks
The OS/2 operating system is designed so that the CPU is never scheduled preemptively while in kernel mode. In general, the kernel either performs its job and exits quickly, or it blocks waiting for I/O (or occasionally a resource). It is not necessary for the device driver to issue both a Yield and a TCYield; the Yield function is a superset of the TCYield function.

Physical device drivers (particularly those that perform program I/O on long strings of data or that poll the device) can use a lot of CPU time. These physical device drivers should check the Yield flag periodically and call the Yield function to yield the CPU if another process needs it. Most of the time the context won't switch. Yield switches context only if an equal, or higher, priority thread is scheduled to run. The address of the Yield flag is obtained from the GetDOSVar service, which is used to get the addresses of kernel variables. See GetDOSVar.

For performance reasons, the physical device driver should check the Yield flag once every 3 milliseconds. If the flag is set, then the physical device driver should call Yield. Because the physical device driver can relinquish control of the CPU to another thread, it must not assume that the state of the interrupt flag will be preserved across a call to Yield.

C

 * 1) include "dhcalls.h"

USHORT APIENTRY DevHelp_Yield 