home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / SLEEP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.5 KB  |  56 lines

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