yield to another process at the same priority


#include <sys/kernel.h>
void Yield( void );


The kernel function Yield() checks to see if other processes at the same priority as that of the calling process are READY to run. If so, the calling process yields to them and places itself at the end of the READY process queue. Yield() never yields to a lower priority process. Higher priority processes always force a yield the instant they become READY to run.

Note: You should avoid designing programs that contain busy wait loops. If its unavoidable, Yield() can be used to reduce the system load at a given priority level. Note that a program that calls Yield() in a tight loop will spend a great deal of time in the kernel, which will have a small effect on interrupt latency.


#include <stdio.h>
#include <sys/kernel.h>

int main( void )
    int i, sum;

    sum = 0;
    for( ;; ) {
      /* Process something... */
      for( i = 0 ; i < 100 ; ++i )
        sum += fun( i );

      /* Yield to anyone else at the same priority */
    return( EXIT_SUCCESS );

int fun(int i)
    int j, k;

    k = 0;
    for( j = 0 ; j < i ; ++j )
      k += j;

    return( k );



Interrupt handler No
Signal handler Yes
Thread Yes

See also: