home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / SLEEP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.8 KB  |  58 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - sleep.c
  3.  *
  4.  * function(s)
  5.  *        sleep - suspends execution for interval
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18.  
  19. #include <dos.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            sleep - suspends execution for interval
  24.  
  25. Usage           unsigned sleep(unsigned seconds);
  26.  
  27. Prototype in    dos.h
  28.  
  29. Description     With a call to sleep, the current program is
  30.                 suspended from execution for the number of seconds specified
  31.                 by the argument seconds. The interval is only accurate to
  32.                 the nearest hundredth of a second, or the accuracy of the
  33.                 MS-DOS clock, whichever is less accurate.
  34.  
  35. Return value    None
  36.  
  37. *---------------------------------------------------------------------*/
  38. void sleep(unsigned seconds)
  39. {
  40.     struct     time    t;
  41.     register int    secs;
  42.     register int    hunds;
  43.  
  44.     gettime(&t);
  45.     hunds = (t.ti_hund > 90) ? 90 : t.ti_hund;
  46.     while (seconds--)
  47.     {
  48.         secs = t.ti_sec;
  49.         do
  50.             gettime(&t);
  51.         while (secs == t.ti_sec);
  52.     }
  53.     do
  54.         gettime(&t);
  55.     while (hunds > t.ti_hund);
  56. }
  57.  
  58.