home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 362_01 / test1.c < prev    next >
C/C++ Source or Header  |  1991-12-10  |  2KB  |  45 lines

  1. /*****************************************************************************
  2.  *                    test1.c                     *
  3.  *****************************************************************************
  4.  * DESCRIPTION:    Verification routine for the RMAXTask multitasking system.   *
  5.  *                                         *
  6.  *        Check that tasks of equal priority share the CPU properly.   *
  7.  *                                         *
  8.  * REVISIONS:     3 JUL 90 - RAC - Original code                     *
  9.  *****************************************************************************/
  10.  
  11. #include    <stdio.h>
  12. #include    <dos.h>
  13. #include    "\rmaxtask\source\rmaxtask.h"
  14.  
  15. int    break_handler() {
  16.     stop_RMAXTask();                /* Do 'about to die' cleanup */
  17.     printf("\nCtrl-Break pressed.  Program terminated.\n");
  18.     return 0;                    /* This will abort program */
  19.     }                        /* End break_handler() */
  20.     
  21. void alpha() {
  22.     for (;;) {                    /* Repeat forever */
  23.     printf("Alpha\n");            /* Print something */
  24.     yield();                /* Yield to other task(s) */
  25.     }                        /* End 'repeat forever' */
  26.     }                        /* End alpha() */
  27.  
  28. void beta() {
  29.     for (;;) {                    /* Repeat forever */
  30.     printf("Beta\n");            /* Print something */
  31.     yield();                /* Yield to other task(s) */
  32.     }                        /* End 'repeat forever' */
  33.     }                        /* End alpha() */
  34.  
  35. void main() {
  36.  
  37.     start_RMAXTask();
  38.     ctrlbrk(break_handler);            /* Establish break handler */
  39.     create_task("alpha", alpha, STANDARD_PRIORITY, STANDARD_STACK);
  40.     create_task("beta", beta,  STANDARD_PRIORITY, STANDARD_STACK);
  41.     wait_key(18 * 1);                /* Run for 1 second or until */
  42.     stop_RMAXTask();                /*  a key is pressed */
  43.     printf("Done with main task.\n");
  44.     }
  45.