home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1989 / 07 / hitech / cotest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-23  |  1.4 KB  |  63 lines

  1. #include <mylib.h>
  2. #include <coproc.h>
  3.  
  4. int c1, c2, c3 ;
  5.  
  6. void far coproc (void)
  7. {
  8.   WIN *w ;
  9.   int ch ;
  10.  
  11.   /* Initialisierung */
  12.   w = define_window (EFRAME,(BLUE<<4)+LIGHTGRAY,(BLUE<<4)+WHITE," COPROC ");
  13.   open_window (w,HERE*5,(HERE<<1)+4,HERE*5+30,(HERE<<1)+14,(BLUE<<4)+YELLOW);
  14.   clrscr();
  15.   writef ("Coroutine %d\n",HERE);
  16.   coreturn();
  17.   do {
  18.     swap_window (w);
  19.     writefxy (1,3,"Stack : %u\n",costackfree());
  20.     ch = getkey();
  21.     switch (ch) {
  22.       case '1'  : if (HERE != c1)
  23.                     transfer (c1);
  24.                   break ;
  25.       case '2'  : if (HERE != c2)
  26.                     transfer (c2);
  27.                   break ;
  28.       case '3'  : if (HERE != c3)
  29.                     transfer (c3);
  30.                   break ;
  31.       case '0'  : close_window();
  32.                   exitcoproc();
  33.                   break ;
  34.       } /* end switch */
  35.     }
  36.   while (1);
  37. } /* end of coproc */
  38.  
  39. int main (void)
  40. {
  41.  
  42.   init_windows (0);
  43.   initcoproc();
  44.   /*  Einrichten der Coroutinen */
  45.   if ((c1 = newcoproc (coproc,1024)) == -1)
  46.     return (255);
  47.   if ((c2 = newcoproc (coproc,1024)) == -1)
  48.     return (255);
  49.   if ((c3 = newcoproc (coproc,1024)) == -1)
  50.     return (255);
  51.   /*  Initialisierung der Coroutinen */
  52.   transfer (c1);
  53.   transfer (c2);
  54.   transfer (c3);
  55.   /*  Start des Zyklus */
  56.   transfer (c1);
  57.   /*  Ende des Programms */
  58.   remcoproc (c1);
  59.   remcoproc (c2);
  60.   remcoproc (c3);
  61.   return (0);
  62. }
  63.