home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / sleep.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  1.0 KB  |  41 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. //
  14. //    Stop the process for a while
  15. //
  16. void _APICALL
  17. DosSleep ( unsigned long delay )
  18. {
  19.     while (delay) {
  20.         if (delay > USHRT_MAX) {
  21.             DosDosSleep ( USHRT_MAX ) ;
  22.             delay -= USHRT_MAX ;
  23.         } else {
  24.             DosDosSleep ( delay ) ;
  25.             delay = 0 ;
  26.         }
  27.     }
  28.  
  29.     //
  30.     // Yield current timeslice under Windoze or OS/2
  31.     //
  32.     // Under native OS/2 a DosSleep(0) relinquishes only if a higher
  33.     // priority thread is waiting, and a DosSleep(1) always relinquishes
  34.     // to waiting threads.  Whatever happens, the CPU is yielded.
  35.     //
  36.     // This code, as does the rest of the library, assumes DOS 3.3 or
  37.     // later.  Earlier versions of DOS have a 0:0 INT 2F vector.
  38.     //
  39.     _AX = 0x1680 ;
  40.     geninterrupt(0x2f) ;
  41. }