Op Code (Hex) | ||||
---|---|---|---|---|
0610 |
Bound program access |
---|
Built-in number for YIELD is 539. YIELD ( ) |
Description: The dispatching algorithm is run. If another thread of equal or higher priority is eligible to run, then a thread is chosen and dispatched. Otherwise, the current thread resumes execution.
The yield() function is a common technique used on other platforms to serialize on a resource or to allow other threads of equal or higher priority to execute before the current thread begins execution of a long running function.
A "spin" lock is a high speed synchronization primitive in which the application "loops" on the setting of a variable which is used to synchronize access to a resource. A typical application implementation of a spin lock might be:
The yield() function allows a thread to immediately relinquish control to a thread of equal or higher priority. On other platforms, this is done because the kernel can not (usually) be preempted. On i5/OS®, the duration of time another thread of equal or higher priority may be prevented from executing until the current thread reaches time-slice end is considered to be very large, especially considering the processing speeds of current machines.