home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / ISC365 / EXAMPLE3.CPP < prev    next >
C/C++ Source or Header  |  1992-10-29  |  2KB  |  64 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //                                                                          //
  3. //                             example3 of ISC...                           //
  4. //                             ------------------                           //
  5. //                                                                          //
  6. // - Do some background processing (just slow down forground...).           //
  7. //                                                                          //
  8. //////////////////////////////////////////////////////////////////////////////
  9. //                                                                          //
  10. //                       By:- Ofer Laor (AKA LeucroTTa)                     //
  11. //                                                                          //
  12. //////////////////////////////////////////////////////////////////////////////
  13.  
  14. #include "isc.h"   // ISC.
  15. #include <dos.h>;  // enable, disable.
  16.  
  17. class Background: public ISC {
  18.  
  19.       virtual void isr(void);
  20.  
  21. public:
  22.        void activate(void) {
  23.             ISC::activate (0x8);
  24.        }
  25.  
  26.        Background(): ISC() {};
  27.  
  28. };
  29.  
  30. void Background::isr(void)
  31. {
  32.     static unsigned char recursive= 0;
  33.  
  34.     old_vect();
  35.  
  36.     if (recursive)
  37.        return;
  38.  
  39.     recursive++;
  40.  
  41.     enable();
  42.  
  43.     for (long i= 0; i< 100000; i++) {
  44.         (*((char far *)0xb8000000L))++;
  45.     }
  46.  
  47.  
  48.     recursive--;
  49. }
  50.  
  51.  
  52.  
  53. Background go; // can be either static or dynamic (not automatic- because
  54.                //     it gets used after the program goes TSR).
  55.  
  56. int main()
  57. {
  58.     if (ISC::is_TSR("EXAMPLE3"))
  59.        return 1; // too much processing in background will kill the forground.
  60.  
  61.     go.activate();
  62.  
  63.     return ISC::TSR();
  64. }