home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / TECH / DVA_TCPP.ZIP / DVCRIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-06  |  3.1 KB  |  71 lines

  1. /***************************************************************************\
  2. *
  3. *
  4. *   PROCEDURE         - Critical Region Guards
  5. *
  6. *   PURPOSE           - From DESQview API Manual:
  7. *                       The BEGINC call causes the current task to enter a
  8. *                       critical region during which all multitasking is
  9. *                       suspended.  The calling task is allowed to continue
  10. *                       execution until it calls ENDC or voluntarily gives up
  11. *                       control.  If it voluntarily gives up control (by
  12. *                       waiting for keyboard input for instance) multitasking
  13. *                       is allowed to resume until the task regains control,
  14. *                       at which time multitasking is again suspended.  This
  15. *                       facility can be useful for executing time critical
  16. *                       sections of code and for controlling access to common
  17. *                       resources.  It should be used sparingly to avoid
  18. *                       degrading overall system performance.
  19. *
  20. *                       If another task is using DOS when the BEGINC call is
  21. *                       made, the caller will be suspended until DOS is free.
  22. *                       This means that you are free to call DOS from inside
  23. *                       a critical region.
  24. *
  25. *                       The ENDC call defines the end of a critical region of
  26. *                       code.  Critical regions are entered via the BEGINC
  27. *                       call.  Calls to BEGINC and ENDC may be nested.
  28. *                       Multitasking does not resume until an ENDC call has
  29. *                       been executed for every BEGINC call that has been made.
  30. *
  31. *   GENERAL ALGORITHM - Call the DESQview API BEGINC or ENDC routines.
  32. *
  33. *   INPUT             - none.
  34. *
  35. *   OUTPUT            - none.
  36. *
  37. *   SYSTEM            - Borland's Turbo C++ v1.0 on an EPSON EQUITY III+
  38. *                       running MS-DOS v4.01 & DESQview v2.26.  Should operate
  39. *                       under any MS/PC-DOS 2.x or greater & DESQview 2.x or
  40. *                       greater.
  41. *
  42. *   HISTORY:
  43. *      90-07-28       - Initiated Mark Potter
  44. *
  45. \***************************************************************************/
  46.  
  47. #include <dos.h>
  48. #include "dvaware.h"
  49.  
  50.                                         // begin critical region,
  51.                                         // no time slicing.
  52. void dv_beginc(                            // procedure
  53.    void                                    // no parameters
  54. ) {
  55.    _AX = 0x101B;                        // BEGINC DV API call
  56.    geninterrupt( 0x15 );                // DV API CALL
  57. }
  58.  
  59.  
  60.                                         // end critical region,
  61.                                         // allow time slicing.
  62. void dv_endc(                              // procedure
  63.    void                                    // no parameters
  64. ) {
  65.    _AX = 0x101C;                        // ENDC DV API call
  66.    geninterrupt( 0x15 );                // DV API CALL
  67. }
  68.  
  69. // END DVCRIT.CPP
  70. 
  71.