DevHlp Yield: Difference between revisions
Created page with "This service yields the CPU to a scheduled thread of equal, or higher, priority. ==Syntax== ===C=== USHORT APIENTRY DevHelp_Yield() ===Assembler=== <PRE> MOV DL,DevHlp_Y..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This service yields the CPU to a scheduled thread of equal, or higher, priority. | {{DISPLAYTITLE:DevHelp_Yield}} | ||
This service yields the CPU to a scheduled thread of equal, or higher, priority. | |||
==Syntax== | ==Syntax== | ||
Line 41: | Line 42: | ||
USHORT APIENTRY DevHelp_Yield() | USHORT APIENTRY DevHelp_Yield() | ||
</PRE> | </PRE> | ||
[[Category:DevHlps]] | [[Category:DevHlps]] |
Revision as of 13:27, 2 January 2020
This service yields the CPU to a scheduled thread of equal, or higher, priority.
Syntax
C
USHORT APIENTRY DevHelp_Yield()
Assembler
MOV DL,DevHlp_Yield CALL [Device_Help]
Parameters
C
None.
Assembler
None.
Return Code
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.
Example Code
C
#include "dhcalls.h" USHORT APIENTRY DevHelp_Yield()