home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / EXAMPLES / WINDOWS / IDLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-30  |  786 b   |  47 lines

  1. /* 
  2. IDLE.C
  3. */ 
  4.  
  5. #include <stdlib.h> 
  6. #include <stdio.h> 
  7. #include <string.h>
  8. #include <conio.h> 
  9. #include <time.h> 
  10. #include <pharlap.h>
  11.  
  12. #ifdef __WATCOMC__ 
  13. #define _kbhit kbhit
  14. #endif 
  15.  
  16. void Yield(void); 
  17.  
  18. main(int argc, char *argv[]) 
  19.     time_t t1, t2; 
  20.     unsigned long iter = 0; 
  21.     int do_yield = (argc > 1) ? 1 : 0; 
  22.      
  23.     time(&t1); 
  24.     while (! _kbhit()) 
  25.     { 
  26.         if (do_yield) 
  27.             Yield(); 
  28.         iter++; 
  29.         if ((time(&t2)-t1) >= 60) 
  30.             break; 
  31.     } 
  32.     time(&t2); 
  33.      
  34.     printf("%lu iterations in %lu seconds\n", iter, t2-t1); 
  35.     return 0; 
  36.  
  37. void Yield(void)
  38. {
  39.     SWI_REGS r;
  40.     memset(&r, 0, sizeof(r));
  41.     r.eax = 0x1680;
  42.     _dx_real_int(0x2f, &r);
  43.     return;
  44. }
  45.